Creating a backup of your repositories as mirror repositories
Even though Git is distributed and every clone is essentially 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 ones 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/*
, whereas a bare repository 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...