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/*'

Make a comment!

About Comments

Your email won't be published for any reason. It's only kept for archive reasons if i want to contact you. You can use markdown syntax.