Mirroring Git repos
Here is a quick way to mirror a git repo from one remote to another. This is not only useful for mirroring but also for backups.
The git clone --mirror git@gitlab.com/myuser/myrepo.git
command will create a mirrored repo, which
is pretty much like a bare
repo, but it also maps all local branches to the remote branches and gets all the refs (like tags).
Basically a one to one copy of the remote repo.
Then it can be pushed to the new remote with git push --mirror git@mydomain.com/myuser/myrepo.git
.
If you ever need to update the local clone with commits from the old remote (or the new one) it can be done
with git fetch --all
.
And done, a nice easy way to move entire repos.