Back up your repositories as mirror repositories
Though Git is distributed and every clone essentially is a backup, there are some tricks that can be useful when backing up Git repositories. A normal Git repository has a working copy of the files it tracks and the full history of the repository in the .git
folder of that repository. The repositories on the server, the one you push to and pull from, will usually be bare
repositories. A bare
repository is a repository without a working copy. Roughly, it is just the .git
folder of a normal repository. A mirror
repository is almost the same as a bare
repository, except it fetches all the references under refs/*
, where a bare only fetches the references that fall under refs/heads/*
. We'll now take a closer look at a normal, a bare
, and a mirror
clone of the Jgit repository.
Getting ready
We'll start by creating three clones of the Jgit repository, a normal, a bare, and a mirror clone. When we create the first clone, we can use that as a reference...