I need Help with Git Clone a live website

I just inherited a git enabled website. My goals are

  1. Clone this site to my local machine (Windows 7)
  2. Create a repository for this site at Bitbucket
  3. Push changes from my local machine to Bitbucket and then pull those changes to the live site.

This simple goal is challenging because the former developer left a very scant documentation and I am completely new to git.

Here is what I have:

  1. I have installed SourceTree client
  2. I have created an empty repo at Bitbucket and
  3. I have access to the live site.

Now for some reason best known to the former developer, this site does not have a repo at Bitbucket rather he was pushing his updates from he development machine to the live site directly. And to further confuse me, in the live site, I found two files id_rsa.bitbucket and id_rsa.bitbucket.pub in /home/user/.ssh and also when I cat /home/user/.ssh/config/ I found

Host Bitbucket.org
User username
IdentityFile ~/.ssh/id_rsa.bitbucket

Now using SourceTree when I try to clone


I get an access denied error. I get an access denied error. Now I was entering my standard ssh password.

So I was thinking maybe it is because my Windows machine does not have an SSH client, but then I saw that SourceTree have a tool to create or import ssh keys, I tried that but then it created a .ppk key and not a .pub key. In any event I am already confused.

Please I can use any help, if you need more clarification, please let me know. Thanks

1 answer

1 accepted

Hi Val,

You're doing something similar to what I did with many repositories recently. The good news is that it's quite straightfoward.

  1. Regarding step 1, are you saying that the site is already in source control? If so, you can just clone it to the directory you'll be using for development as usual.
  2. Steps two and three can be two-fold. If the folder isn't already in source control you can drag and drop the folder into SourceTree and it'll prompt to create a repository. The following is what happens if I drag a folder which isn't in source control (i.e. doesn't have a .git or .hg folder in it) into SourceTree:

    It will automatically open the "Create Repository" tab for me which will initialise a repository on my behalf. Ignore this if your project folder is already in source control (either git or mercurial).
  3. OK, so whether you've created a fresh repository or are using an existing repository it doesn't matter so much, you basically need to change (or create) where you're pushing to, that is, the 'remote'. To do this look at your sidebar in SourceTree and there's a section called "Remotes". Make sure it's expanded - when you hover over it there's an 'expand' text next to it. This will show you the remotes, but you'll want to be editing them anyway. Instead, go to the "Settings" section of your repository which is on the very right-hand side of the toolbar. This view is the one you'll want to work with.

    If you click on "Add" you can add a new remote and specify the remote name and the remote path. If you've hooked up SourceTree so it links with your Bitbucket accounts then you can click on the "globe" icon and select that repository. If it's a brand new repository on Bitbucket then you should be able to push to it.

So, the developer was committing to a local repository and publishing the changes to the live site. This does have its drawbacks so you're right in setting up a repository with Bitbucket.

Those two files are your SSH keys, both public and private. Make sure you don't put these into source control otherwise they'll be published to the Internet (this has been a well known problem in recent times). Keep your private key very, very safe. Having your keys setup means that you can pull/push changes without having to explicitly authenticate. They should be kept in ~/.ssh/.

There's a guide to SSH keys here which will help: https://confluence.atlassian.com/pages/viewpage.action?pageId=271943168. Usually you just set up id_rsa and id_rsa.pub and put them in that folder. If you're dealing with multiple keys (because yours is named differently I presume it's multiple keys) then you'll need to set up a ~/.ssh/config file. The link will help you with this. Make sure your public key is put into your Bitbucket account settings. There's a section in that article called 'Load each key into the appropriate Bitbucket account' which will help you with this.

That should address everything you need, but feel free to ask more questions once you've gone through the above carefully, and read the linked article to help set up your SSH keys.


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

965 views 4 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you