Tuesday, September 16, 2008

GITting Around

I've been very busy for the last 3 months or so, but now can start to blog again.

A few things have changed. One of them is source control. GIT is working out really well. I highly recommend people drop SVN in favour of it. You can get an overview and tutorial from many places, so I won't bother repeating any of that. For folks developing in a windows environment, I can help a bit with some specific issues one might run into with the switch.

1. Upon installing MSysGIT, the AutoCRLF setting should be set to false before you do anything unless you are writing a multi-platform app. If you don't, you run into the danger of having your CRLFs changed to LFs in the repository. Then GIT will report file changes where there are none.

2. Stop all that typing (unless you want to strictly use the GUI via git gui):

git config --global alias.st status
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.br branch
git config --global alias.me merge
git config --global alias.cl clean
git config --global alias.ps push
git config --global alias.pl pull
git config --global alias.rt reset
git config --global alias.rb rebase

If you want to configure bash on your machine, you could make aliases at that level - such as gci for "git commit".

3. Unless your SVN repo followed a strick trunk, branch, tag structure, don't bother with the standard layout option for cloning SVN with git svn. This leads to more headaches in the end. It's a long running process, so get it right the first time. Use --follow-parent to track moves, copies and renames.

4. Get hosting. Unfuddle is great as a free host environment. Don't get scared about the 200MB limit on the repository. GIT is very efficient and will take 1/30th the space that a SVN repo took. Unfuddle will email you when there are commits. It parses commit messages as well, so you can close an issue (tracked in unfuddle) with something like "closes #435". A commit with that message will close issue 435 in unfuddle. For $9/month you can get more users, 500MB limit and file attachments. The file attachment is a waste. I use www.drop.io to host files.

5. Setup your remote branches so you can simply "git ps" and "git pl" to send commits and receive commits from the remote repo. If you have a remote repo for the remote team over in India, you could set up something like this in the .git/config file for an "india" branch:

[remote "india"]
    url = git@mycompany.unfuddle.com:mycompany/outsourced.git
    fetch = +refs/heads/india:refs/remotes/india/master
    push = india:master
[branch "india"]
    remote = india
    merge = refs/heads/master

6. Read up on GIT. It's quite different from SVN.

No comments: