Posts for tips

Single backup repo with git

Well as Linus says, with git he doesn't do backups, and it's true that dvcs partially solve the backup problem as long as someone has cloned your repo.

For those branches that are not published yet you have to take backups. Instead of setting up a backup repo for every project you could use a single one for all of them! Every project will have it's own prefix so the namespace stays consistent.

mkdir ~/backup
cd ~/backup
git --bare init

cd projectA
git remote add backup ~/backup
# You probably don't want to fetch from this repo
git config remote.backup.fetch ''
# Push branches to a project namespace
git config remote.backup.push '+refs/heads/*:refs/heads/projectA/*'

git push backup

If you want to track the backup branches you can do it with the following fetch refspec:

git config remote.backup.fetch '+refs/heads/projectA/*:refs/remotes/backup/*'

git coolness

I am using git to track my home directory, using a branch for every pc I use. Tracking large directories like home can be quite annoying: git status for example will try to stat every file for changes, and produces a 3-4 page output where all the useful information is 3 pages up from your cursor! The same happens with git commit editor.

Luckily, git supports status.showUntrackedFiles option.

git config status.showUntrackedFiles no saves the option to you .git/config file. The results:

$ git status|wc -l
240
$ git config  status.showUntrackedFiles no
$ git status|wc -l
7

Nice stuff :)