Mirror a git repository
In order to mirror a git repository from one remote to another, first clone it with --mirror
:
git clone --mirror <repo.git>
(This will leave a bare copy of the repository, containing an internal directory structure with the object.)
Then add the new remote (let’s call it mirror-remote
) which will hold the mirror:
git remote add mirror-remote <mirror-repo.git>
Now push all the stuff to the mirror-remote
:
git push --mirror mirror-remote
That’s all! Now every time you want to update the mirror just fetch the new stuff and push it:
git fetch
git push --mirror mirror-remote