Skip to content

Git on Ubuntu with a Windows Client

September 4, 2010

If you happen to have a decent Linux VPS lying around you might get it into your head to set up your own private git repository to stash your various writings, recipes, world domination plans, and the occassional LOLcats picture. This is a bit easier said than done so I thought I’d take a moment to document my own efforts.

I’m assuming that you have an Ubuntu server and a Windows client. The first step is to get git installed on the server. But before this can be done you’ll need to generate a SSH keypair. See the Ubuntu SSH keys tutorial for how to do this and once you’ve done so use WinSCP to grab a copy of your private key (the one that doesn’t end in .pub) and stash it in the C:\Documents and Settings\$USER\.ssh directory.

Now you can go ahead and install git and gitosis on your Ubuntu box. Be sure to initialize gitosis using the correct public key. Also note that gitosis may store your public key in a file named $USER@$HOST.pub in its keydir directory. This will only cause problems later so rename it to simply $USER.pub. You’ll also need to modify, commit and push gitosis.conf to refer simply to your username.

Now create a new repository in gitosis. Make sure you run the mysterious git remote add origin gitosis@$HOST:$PROJECT.git command and make sure you can then push the new origin to the remote master. You should now be able to modify, commit and push on the server. It’s time to setup the Windows client.

Install msysgit on your Windows box. The net install can be very flaky. If it breaks on you just delete the C:\msysgit directory and run the full install.

Now install Tortoise Git. When you do, as noted here, be sure to tell Tortoise Git to use the OpenSSH, Git default SSH Client and not TortoisePLink.

Now you can go ahead and clone the repo you created on the server using Tortoise Git. The repo URL will be of the form gitosis@$HOST:$PROJECT. Note that unlike the Linux git client, Tortoise Git doesn’t seem to like it when you add a .git to the end of the repo name. Also note that the username is gitosis. Technically you could use other usernames here, like your own, but then you won’t be able to share the repo.

Make some changes in the repo and commit. But if you try to push your changes back to the master you’ll get a very strange error message telling you you’ve already checked out the ‘master’ branch. In fact you have: on the server, when you initially created the repo. To fix this you’ll need to convert the repo on the server to a bare repository. Once this is done you can now happily commit and push away!

Enjoy!

From → ubuntu

One Comment

Trackbacks & Pingbacks

  1. Git and Egit « Beautiful Discovery

Leave a comment