Friday, December 7, 2007

Replacing Subversion with Git for version control

I downloaded git on one of my fedora machines (fedora 7) to get a feeling for how it works vs subversion. I used yum to get the latest version ( with this command:
sudo yum install git
Before getting started with git, first thing is to establish some global configurations. The standard configs are saved in ~/.gitconfig (currently in config/common). There is also a ~/.gitk config file that should be modified for the mac (put in config/osx/sedona) to set the font to Monaco 12 rather than Helvetica 9.

Using Git: There are tutorials for using git on the main site and one for subversion users. After the installation, I used the tutorial to establish tracking to some basic accounting files, time sheets, check register, etc. It started like this.
cd accounting
git init
git add .
git commit
Now the accounting directory is under source control. Another great resource for git is from peepcode.

Remote Repository: The next step is to get a remote repository established. I played around with the git socket protocol on, but found it a bit too confusing. So after reviewing the peepcode git session, I decided to use ssh and a restricted shell for the remote repository. I followed these steps:
  • login to the remote machine (
  • create a new 'git' user: useradd --shell /usr/bin/git-shell git
  • copy to the server: scp -r accounting
  • create a /public/git folder and move the accounting to it
  • set owner to git:git
So it wasn't too difficult. After running clone, I did a few push and pulls from different machines and watched the changes on the remote repository. Works good...

No comments: