Using Gitorious, TortoiseGit, and Msysgit Together

And Not Crying!

So if you’ve read previously I’ve setup a Gitorious server at my work to do some POC that doesn’t necessarily need to go into our source control systems for standard release software.

Up to this point I’ve only used the CLI on Ubuntu to issue git commands. I kinda was at a loss on how to work with Git on a Windows machine. Since I’ve used TortoiseSVN and I knew there were other Tortoise* derivatives I checked to see if there was a flavor that supported Git. Turns out there is, TortoiseGit.

TortoiseGit is just an interface which integrates into the Windows shell to provide support for Git for Windows. For us point and clickers it is great. It does still allow for dropping into a BASH emulator for doing more complex commands. For me, it allows me to execute the same commands that I would on my Ubuntu machine at home.

Anyhow, after I got Gitorious up and running with LDAP authentication I wanted to be able to pull and push without having to do any real work. After some head banging I found that I should just use the SSH authentication to do this. Comment if you’ve found a way to do LDAP authentication through the TortoiseGit or Msysgit BASH interface.

Here’s how to set it up:

The first thing you’ll want to do is create a public and private key. On Ubuntu this is pretty easy using the OpenSSL package. Thankfully, when you install TortoiseGit it also installs PuTTYGen, PuTTY Key Generator (you can also download it at the provided link if needed). Open up PuTTYGen, select Key from the menu bar, select SHA-1 or SHA-2, and then select Generate key pair from the same menu location.

PuTTY Key Generator

Follow the instructions to randomize input and create your key-pair.

PuTTY Key Generator

When you’re key is created you’ll see the screen as below.

PuTTY Key Generator

Before you continue you should go ahead and save your public and private keys. I suggest you use a passphrase to protect your private key. I saved my keys to two locations, one in the My Documents area as backup and the other to be used by the Msysgit BASH environment. The Msysgit BASH environment treats your C:\Users\\ as your home folder. This means that just as in Ubuntu (or any other Linux distro) git will look for the .ssh folder for your public and private keys. Save your public key to C:\Users\\.ssh\

You’ll notice that when you click the Save private key button that it will save it as a .ppk file. This file type cannot be used by the Msysgit BASH shell. Go to the Conversions menu item and select Export OpenSSH key. Save this to C:\Users\\.ssh\id_rsa. Now when you issue git commands from the BASH shell it will use those as your public and private keys. Remember to still save your private key as a .ppk file! TortoiseGit will need it.

Before exiting out of PuTTYGen copy the public key from the top text area into your account at Gitorious. Your SSH keys are located under your account, SSH keys.

Add new public SSH key - GitoriousGitorious SSH Keys

At this point you’ve placed your public and private keys in the .ssh folder for Msysgit BASH and your public key is stored on Gitorious. You can now use the BASH shell when interacting with Gitorious. On our local network I would pull from<project_name>/<repository_name>.git and not be asked for a username or password. Doing a push would be the same. Gitoroius does it’s awesomeness and shows everything for us!Project Example - Gitorious

Now that we have done most of the work. The last thing to do is to get TortoiseGit to send the private key when it does its operations. Now, before we continue let me point out one thing. I’m not sure if you can stop at this point or not. I’ve not normally setup the environment in this order. Normally I get TortoiseGit working first then add my keys to the .ssh folder to get the BASH shell working. My theory is that TortoiseGit using Msysgit wouldn’t need any more configuration and will use those keys. Test this out and let me know in the comments. However, for the sake of completeness and the fact that some may not ever want to touch a command line I’ll show how to setup TortoiseGit so that it will use your private key.

From this point forward I’m working with a single repository.

Open a Windows Explorer window, go to the location where you’ll store your git repository (I keep mine in projects/git/<project_name>), right click, select TortoiseGit, and then select Settings.

TortoiseGit Settings

Now we’re going to edit the remotes and add our origin remote.

origin Setup

Add the remote origin and give it the URL from the repo page. Click the “…” button next to the text box for Putty Key. Select the .ppk file that was created from the PuTTYGen step. Finally select the Add New/Save button.

Once you’ve done this you can pull and push using the TortoiseGit GUI!

Post your questions or let me know if I missed anything in the comments!

About Mike

I'm a software engineer. Look into the about page for more information about me.
Tagged , , , , . Bookmark the permalink.

Leave a Reply