How do I backup a git repo?
The akira answer is correct, but you can add --mirror to create a bare repo (for a slightly smaller backup).
We use the following strategy (almost exactly):
git clone --mirror yourrepo backup.repo
tar cjf backup.repo.tar.bz2 backup.repo
scp backup.tar.bz2 ssh://somewhereelse
Then, to recover from your backup:
tar xjf backup.repo.tar.bz2
git clone backup.repo yourrepo
You just copy it. git does use a repo folder, it's just hidden from normal directory views. (The folder is named .git
on *nix systems, so it only appears if you use ls -a
. I assume that it sets the "hidden" attribute in Windows, but I've never used git in a Windows environment, so I'm not certain about how it's handled there.)
I'm using git bundle. For making a copy file (one backup file) execute:
git bundle create backup.bundle master
To restore the repository with branch master simply clone the backup.bundle file:
git clone backup.bundle -b master my-project