Git

Why does SourceTree fail to connect to my Git repo on Windows?

I’m a big fan of SourceTree by Atlassian. While purists might scoff at a GUI for Git, I find my normal workflow much improved by a few pretty pictures. And for the tough stuff, the Terminal is dedicated button on the main repo view.

What stinks about SourceTree, at least on Windows, is that the Putty/Embedded Git toolchain they default to never seems to work on the first try. Of course, that’s no problem since they offer an option to use the system’s copy of Git with OpenSSH instead. It works smooth as butter almost all the time.

Don’t have any of this yet? To start, first download Git from the main site:
https://git-scm.com/download/win

Just use the main download and use the default options, they are pretty good and go to extensive lengths to make sure your path isn’t broken by the Unixy nature of Git. You’ll get a new terminal emulator called MinTTY, which safely contains all of the new path changes.

Open up your new terminal, the start button shortcut will be labeled “Git Bash”. Now we can generate your ssh key. The command you want is:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

Once again you can just follow the default prompts. But Santa Claus will put you on his naughty list if you don’t enter a passphrase.

Your key files got saved in your home directory. You’ll need to upload your public key (*.pub) to your Git repo host (e.g. Github, Gitlab, etc.). The private key you’ll want to set SourceTree to look at, as well as changing SourceTree options to use OpenSSH (under the General tab) and the system copy of Git (under the Git tab).

Capture

Capture

That should be enough to set you straight. Good luck and happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *