How do I backup a git repo?
Solution 1:
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.)
Solution 2:
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