Backup and Restore Git Repositories

Sometimes you need to move repositories from your local git server to github.com, bitbucket.org or vice versa. the situation where you want to archive the whole "bare" repo, not just a clone with the master or a single branch.

Backup can be done simply by adding --bare to the clone command

git clone --bare git@github.com:modsaid/test-repo.git

This will result in a cloned repo on the filesystem that is similar in structure to a bare repository

Restoring can be done by creating an empty repository on your git server (github.com or bitbucket.org). and running

cd test-repo.git
git push --mirror git@bitbucket.org:modsaid/test-repo.git

voila

Comments

Unknown said…
HOw to do a clone repository in local linux server

Popular posts from this blog

Ruby script for downloading rails casts

Stress Testing with Siege and Bombard, know your limits

Exporting data from remote mysql instance in csv, using mysql client and sed