Setting up Git and TortoiseGit with Bitbucket, step by step

I wanted a set of instructions for my colleagues and friends when they want to setup Git and TortoiseGit on Windows (connected to Bitbucket). There are some steps that I have to Google myself too every time, because I don’t install Git & TortoiseGit everyday.

Okay, so this post is going to be a bare-bones, step by step guide for me or anyone (No backgrounds, theories and other noise)


  • Git – is a free and open source distributed version control system.
  • TortoiseGit – is a Git client (GUI interface).
  • Bitbucket – is a web-based project hosting service (supports Git and Mercurial)


  • You already have a Bitbucket account. If not, you can create one here.
  • I’m installing this on Windows 7 – 64bit. I assume you can adapt to minor differences in your flavor of Windows.


Installing Git

1. Download the latest Git for Windows →

2. Start the installation and continue clicking “Next” until you come to the “Select Components” view (see below).

We only mark “Git Bash Here”, as shown in the image (This will add an entry in the right-click context menu of folders) →

 Select Git components during installation

3. Continue clicking “Next” without changing anything and finally click “Finish” to complete the setup. We have completed installing Git.


Configure Git settings

1. Click Start Menu and type “Git Bash” and press Enter to open a Git command-line window

2. Provide your name and email address to Git, so that it will label your commits properly.

For example, if you want your name to look like “John Doe” in your commits and your email address (registered with Bitbucket) is, you would enter the following two commands (press Enter after each line) →

git config –global “John Doe” git config –global “”

This is how it would look in Git Bash →

Setting username and email address in git


Create SSH identity and copy public key to clipboard.

To make sure we don’t enter our username and password every time we push to or pull from the Bitbucket repository, we should use SSH (secure shell) to communicate with Bitbucket. Lets go ahead and create our SSH identity to communicate with Bitbucket.

1. Click Start Menu and type “Git Bash” and press Enter to open the Git command line (if it is not already open)

2. Type the following command and press Enter →

ssh-keygen –t rsa –C “”

(Use your email address registered with Bitbucket)

You will be prompted to provide file location and to enter a passphrase twice. Keep pressing the Enter key to accept the default file locations and to skip providing a passphrase.

Now the key files are generated. Easiest way to copy the contents of the public key to the clipboard is to use the “clip” command as follows →

clip < ~/.ssh/

Once you press Enter, the contents will be in clipboard, ready to be pasted.

This is how it will look in Git Bash →

Create ssh identity and associate with bitbucket


Add the copied public key to Bitbucket

1. Log into Bitbucket and click on your avatar (top right-hand corner). Click “Bitbucket settings”

Click Bitbucket settings to manage SSH keys

2. Click on the “SSH keys” link on the left side and click the “Add Key” button to add a new key.

Click ssh keys on the left side in account management page

3. In the “Add SSH key” popup that comes up, paste the copied contents of the public key in the “Key” text box.

4. Provide a label for this key in the “Label” text box, to identify it (optional). For example it could be “Personal Laptop”.

5. Click on the “Add key” button to save and close the popup. Key with the “Personal Laptop” label (or any other name provided) should be listed like in the following image →

Added public key in bitbucket


At this point we have everything ready to work with Git and Bitbucket… ONLY if you are someone who loves the command-line! Winking smile

If you were one of those rare breeds, you wouldn’t even be here reading this guide. So let’s continue and see how we can install and setup TortoiseGit as our GUI interface for Git (there are many other excellent Git clients too, that you can try, e.g.: SourceTree)


Installing TortoiseGit

1. Download the latest TortoiseGit here → (Make sure you select the right setup for your PC – 32bit or 64bit).

2. Start the installation and keep clicking “Next” until you come to the following view (Choose SSH client). Choose “OpenSSH, Git default SSH Client” here.

Choose ssh client

Note: If you don’t see the “Choose SSH Client” option during installation, don’t worry. This can happen if you are reinstalling TortoiseGit (The settings are left behind in a previous installation in the Registry).

If this happened to you, Click “Finish” and try the “Extra Step” provided blow. Then you can continue from “Let’s test our installation” topic.

3. Click “Finish” to complete the setup


Let’s test our installation

We need a valid Git repository in Bitbucket to test our installations and configurations.

Go to an existing repository or create a new repository (this can even be a repository to only test Git with Bitbucket, that you can delete immediately).

1. Click on the “Clone” button on top (next to the “Fork” button).

2. Select “SSH” from the drop-down.

3. You will see a text box to the right with all its text selected. “git clone” is a command and we don’t need that now. So, copy everything else.

This is how it would look in Bitbucket →

Clone repository settings in bitbucket

If you paste the copied text to a text editor like Notepad, it should look something like the following (Note that there’s no “git clone” command in it. If you accidentally copied that too, copy again WITHOUT it).

Some parts will be different for you because you will have a different username and repository name. This is our clone URL.

4. Let’s “clone” the repository on the desktop (you can delete and try a different location later). Right-click on the Desktop and select “Git Clone…” from the context menu.

5. A window will popup. Paste the copied clone URL in the “URL” box and click Ok →

Cloning the repository in Windows

6. If this is the 1st ever time you are communicating with Bitbucket using SSH, you will see the following message (Git doesn’t know Bitbucket as a host yet) →

Bitbucket authenticity warning message

Just click “Yes” to remember in future sessions.

If everything went on fine, you should see a blue success message at the bottom in TortoiseGit once the cloning is complete →

Success cloning repository


Commit a new file to your repository and Push to Bitbucket

Only when you could commit and push a file to Bitbucket without a problem, that we can confidently say our setup works.

Yeah, that’s “home-work” for you and I’m not going to list any steps here Winking smile

Since the purpose of this article was to setup the necessary tools, “how to” work with these tools is beyond scope (Can be discussed in another article maybe).


EXTRA STEP, only if you didn’t get the “Choose SSH client” option

If you didn’t see the “Choose SSH Client” option during installation (which can happen if you are reinstalling TortoiseGit – the settings are left behind in a previous installation in the Registry). You can set this later in TortoiseGit settings after installing TortoiseGit as described below →

  1. Right-click on any folder and select: TortoiseGit → Settings, from the context menu.
  2. Click on the “Network” node.
  3. You will see the “SSH client:” option on the right.
  4. Make sure it has only ssh.exe in it.
  5. Click Ok.

Here’s a screenshot of the Network options in TortoiseGit settings →

Change SSH client in Network options of TortoiseGit Settings


Your feedback!

I want to keep this post as simple as possible for anybody to follow. If you found any areas where it is not clear, please let me know below in the comments, so that I can make sure its simple for everyone.



91 Responses to “Setting up Git and TortoiseGit with Bitbucket, step by step”

  1. […] colleague and resident Git evangelist Guhan has written a very useful blogpost that gives a Step-by-step guide on how to set up Git clients for Windows. If you’re just now joining a Git project, this is exactly what you […]

  2. NDonchev says:

    Thank you very much. That was a great tutorial ;). Everything worked as described.

  3. Magnus says:

    Great article!

    I would recommend the git client SourceTree by Aladdin though. 🙂

  4. Tom W says:

    Great tutorial, saved a lot of pain for me and my colleagues. Nice one Guganeshan.
    Tom W´s last blog post ..Umbraco UK Festival 2013 – heralding the launch of Umbraco 7

  5. Bil C. says:

    Thanks – big help!

  6. Harish says:

    Thanks for sharing the details. I followed the steps. But when I do clone, i get a window with below message:

    “Disconnected: No Supported authentication methods available (server sent: publickey)

    Any gusses?

  7. Harish says:

    Hi. Please ignore my last question. That was due to the wrong open choosen as SSH client.

    Can you please add the instructions for changing SSH client from settings when reinstalling.

    We only have to add ssh.exe without any path. This article would be complete with this info.

    • Guganeshan.T says:

      Hi Harish,

      I didn’t explain that scenario thinking the guide will become complex (only mentioned the possibility of missing the SSH setting page of the wizard)

      I will include that too, so that it will be complete. Thanks for the feedback!

      • Pedro says:

        I get stuck on that part until I check the comment of Harish. So, I prefer the tutorial to be more complexe and more complete rather than incomplete and I took 2h searching for a resoluton…

        Great Info Guganeshan, thank you..

    • Corey says:

      If you do not have git installed in the default location (my C drive is an SSD, so I don’t install many things there) you have to enter the full path, not just ssh.exe.

      For example, I had to enter “D:\Installs\Git\usr\bin\ssh.exe”.

      • Guganeshan.T says:

        Corey, you don’t have to enter the full location of Git if you are using Git Bash itself. But if you are using the standard Windows command line, you can select the option to add Git to the “path” variable during installation. Then there’s no need to enter the full path there too. Or you can add Git’s location to the “path” variable manually.

        Hope that helps

  8. Pooja says:

    This was an extremely useful (comprehensive- just what was needed!) post . Suffered installing GitHub so was advised to try out BitBucket and SourceTree but this helps.

    Thanks a lot! Now to push, pull and commit!

  9. Martin says:

    Great tutorial!
    Just want to add that if you can’t select the ssh client. Just go to right click > tortoisegit > settings > network > and just type ssh.exe twithout any path in front, as mentioned by Harish.

    • Guganeshan.T says:

      Hi Martin,

      Yup, didn’t include that detail to keep the guide simple, as I have mentioned in the reply to Harish.

      But I thought I will add that too, to make it complete.

      Thanks for the feedback!

  10. Devraj says:

    Hi Guganeshan

    can you help me out this with git bash , how to add it with it. Coz i m trying and its always says failed

  11. mag says:

    thanks Guganeshan… you saved my day!!!

  12. Ana says:

    Thank you so much above tutorial works nicely. you save my day. but how to commit and pull?

  13. Ana says:

    now I can commit and pull 😀 Thank you so much, you save my whole week :)))))

  14. Robert Kabat says:

    Cool stuff! Thanks dude! Now I can work like a pro 🙂

  15. dian says:

    Hai Guganeshan,

    I have followed step by step like what you wrote but when I want “CLONE” the repository, I have this error message : git did not exit cleanly (exit code 128)

    Need your advice, please.. Thanks

    • Guganeshan.T says:

      Hi Dian,

      There’ll be more information above that explaining why it didn’t exit cleanly. if you can copy those messages, then we can analyze what went wrong. Sorry for the delayed reply.

  16. Russ says:

    Word of warning: the ‘-‘ character in the command line functions on this web page doesn’t copy paste properly in chrome

    • Guganeshan.T says:

      There was a problem in Chrome. Not only that… after seeing your comment, I noticed that two minus symbols were displayed as one!

      Had to edit the post in HTML level to fix it.

      Thank you for pointing that out Russ! 🙂

  17. Amazing post, Guganeshan! It really helped me to quickly configure Tortoise Git to work with my newly created BitBucket account.

    Thanks for sharing this information with the community.

    Best regards,
    Rui Figueiredo

  18. Vespira says:

    First of all, thanks for this tutorial 🙂 I’ve tried exactly the same steps as yours, but when right-clicking and cloning a repository from bitbucket on a local directory on my computer, it fails with the error : Could not read from the remote repository. I verified your steps one by one, and I can certify you that I’m well configured concerning your post. Where can it come from so ? My antivirus and firewall was disabled for the tests.

  19. Hamelraj says:

    Thanks for your useful article bro…..

  20. guest says:

    Extremely helpfull, thanks a lot!

  21. Sven says:

    Thanks a lot for your very detailed instructions, your time and efforts. It works fine for me…!

  22. Excellent. Loved the tutorial and this is a good way you explained everything. Clear like water.
    Kudos to your effort.

  23. […] folks. It took me some time to grasp it. With the help of Tortoise-GIT, a guide, and some patience I learned to use […]

  24. […] folks. It took me some time to grasp it. With the help of Tortoise-GIT, a guide, and some patience I learned to use […]

  25. Mark says:

    Thanks for the nice tutorial. I had some problems with “error code 3328” after following the tutorial. For all who also encounter that problem: Make sure that the path to Git.exe in the General Settings of TortoiseGIT is set to the newly installed Git-path (probably C:\Program Files (x86)\Git\bin). For some reason this was not correctly set because I had some older console development setup on the same system and it pointed to that one. After that everything worked fine!

  26. Carlos Tre says:

    Thank you very much for the superb guide. Greatly appreciated.

  27. Glenn Dixon says:

    Thanks for this article. After giving up on Sourcetree (crashes constantly on Windows) I almost gave up on git GUI’s altogether. Now up and running and getting ready to put all my sites into BitBucket and get everything synced up!

  28. Dilini says:

    Saved my Day. Thanks Guhan!

  29. Josh says:

    It just worked! I’ve had to do this for multiple computers over the years, a chore made far worse by the many bad tutorials out there. Many just don’t work, some are needlessly complicated and filled with unnecessary steps. Thank you!

  30. Logesh says:

    It is really useful this is great tutorial for GIT

  31. cw22 says:

    Hi, thanks for your guidance. is good!

  32. Jane says:

    THANK YOU!!!!!!!!!

  33. Andrew says:

    Doesn’t work. Tried with latest versions of Git, Bitbucket, & TortoiseGit. I still get prompted for userid/password

  34. Ranga says:

    Very helpful, saved my day !

    Thanks mate ! 🙂

  35. Jens H says:

    Thank you very much, this helped me a lot!

    In my case, as I was trying to setup my machine at work, I received various errors that a connection could not be established.

    It looked more like network related stuff than credential problems, and indeed it was.

    I resolved this by configuring the PROXY settings in TortoiseGit.

    => Giving a hint to this would be a great addition for your artice to help others with the same problems.

  36. Ravi Kumar Gupta says:

    Sir How to upload code in bitbucket.

    • Guganeshan.T says:

      Hi Ravi Kumar… Sorry for the delay. I have not discussed about how to add your existing code to Bitbucket etc. in this post to keep it simple.

      Did you manage to solve the problem?

  37. giri says:

    Hi ,
    first of all thanks for your post. Very nice. If suppose, I want to go with tortoisegit, then I no need to do Configure Git settings ( create ssh key and save it in bitbucketwebsite). i download git and tortoisegit as per your advise and start working or i have to do entire process what you mentioned in this site?

    Please give clear definition about this.because i will go with tortoisegit only. what are all configuration I have to do for this?

    • Guganeshan.T says:

      Hi Giri. Sorry for the late reply.

      You can skip the SSH part and continue. TortoiseGit will ask for your password. Is that what you wanted to know?

      Hope you have already solved your problem.

  38. Ted Thomas says:

    Guganeshan.T you are a hero!

  39. Sun says:


  40. Brittany says:

    This helped a lot, but… I got stuck at the last part.

    There was no way to clone the desktop. I have the options to “git sync” and “git commit -> .” I’m not sure how to clone the directory.

    • Guganeshan.T says:

      Hi Brittany, sorry for the delayed reply. Did you manage to solve the problem?

      You have said “There was no way to clone the desktop” – I didn’t understand what that means. Did you mean to clone something into a folder on the Desktop?

  41. Nina says:

    Great tutorial, perfect work!

  42. Pubudu says:

    Grate stuff guhan.. It saves my time.
    Little update for RSA key generation.
    Git Version: 2.7.0-64bit

    Command works for me:
    ssh-keygen -t rsa -b 4096 -C “”


  43. Pubudu says:

    Little update for my previous comment. Seems like a character is different. Other wise guhan’s command should work regardless of Git Version.

    ssh-keygen –t rsa –C “”

    use “-(En dash) instead –(Em dash)”

    Following command works:
    ssh-keygen -t rsa -C “”

  44. Doug says:

    Very nice setup tutorial. Feb 17, 2016 I downloaded the most recent versions of git and tortoiseGit and each step worked perfectly. Thank you for taking the time to document this!

  45. Bruce Thwaits says:

    I bookmarked this link ages ago. I still come back to it every single time I need to do this setup. Thank you so much for putting it all down in such a concise format so it’s such an easy reference 🙂

  46. Richard says:

    Excellent description and a lifesaver as I was struggling with bitbucket and windows

  47. Hello Guganeshan,

    First of all, thank you very much for your excellent blog on how to set up Git and TortoiseGit with Bitbucket. It has been a life-saver.

    I took the liberty of writing down alternative steps, for those who want to combine TortoiseGit for Bitbucket with GitHub for Windows, on the same PC:


  48. Aca says:

    Thank you so much! I hope you submitted it on reddit so people can find it easily.

  49. […] To establish the proper version control system on my PC, I have used these clear and intuitive instructions from Guganeshan Thambiraja’s blog. Below, I summarize the actual […]

  50. John Anson says:

    Thank you. Excellent instructions.

    A slight change now that Atlassian has taken over BitBucket:
    Add the copied public key to Bitbucket
    1. Log into Bitbucket and click on your avatar (top right-hand corner). Click “Manage Account” -> Click “BitBucket Settings”

Leave a Reply

CommentLuv badge