Here are the top few things I learned about Git, mostly in the first few hours I used it. This is the document I wished I had had, on top of the various introductions floating around. Maybe it will be useful to somebody else.
-
Git handles 400MB of HTML crawl data less gracefully than it handles 700K of Python. But it handles that data more gracefully than
cpandrsyncdo. -
Don't
git pushto a repository that actually has a work area. Always usegit pullinstead.git pushdoesn't update the associated working area, or the index either, so if you try togit commitin that repository, you will commit a patch that undoes all the stuff you just did. See http://utsl.gen.nz/talks/git-svn/intro.html section "Push changes and the working copy". You can solve this withgit reset --mixed HEAD, or eventuallygit reset --hard HEADto throw away any changes in the working area.23:05 < johnw> $ rsync -av .git/ server:/tmp/foo.git/ ; cd /tmp ; git clone ssh://server/tmp/foo.git 23:06 < johnw> that's all you need to setup a remote repository, and to start using it right away -
git repack -a -d -fcan achieve some truly astonishing compression ratios. This is how you make git checkouts faster thancp -aorrsync. In my case, three times faster thanrsyncover a slow network, due to a 7:1 compression ratio. -
You have to
git addchanged files before you cangit committhem, or usegit commit -a, becausegit commitcommits things from the index, not your work area. In older versions of Git, you usedgit update-indexinstead ofgit addon changed files. -
git committakes an option--amendwhich lets you amend the previous commit.git rebase --interactivelets you amend previous commits in general. Both of these don't really work if you've shared the commits with someone else. -
git clone -lmakes a hardlinked clone. (This is default in newer versions of Git. It's another factor in making git checkouts fast.) -
git has early-stage support for something called "submodules" in recent versions, similar to
svn:externals. And there's an in-developmentgit hunk-commitcommand that might end up in git someday that should add most of Darcs's UI niceness to git, althoughgit guiorgit add --interactiveget you partway there already. http://raphael.slinckx.net/files/git-darcs-record02:38 < twb> I found git commit --interactive pretty confusing.
02:39 < andreaja> twb: I prefer to use git add -p -
If you try to
git pullwhen you have un-checked-in changes,gitwill complain with an unhelpful error message. Check in the changes orgit stashthem before you pull.
I took the first 125 563 056 bytes of my mailbox and compressed them into 59M with git. However, git (1.4) doesn't seem to work very well with multi-gigabyte quantities.
If you're using the Git 1.4 from Debian Stable, you'll want to know to
use init-db instead of init, repo-config instead of config,
and often update-index instead of add.
http://cheat.errtheblog.com/s/git http://www-cs-students.stanford.edu/~blynn/gitmagic/