I'm a solo developer, working in a local Git repository. For backups, I want to send an exact copy of that repository off to another server.
Is it sufficient to do this?
git push --mirror
I'm asking because I can sometimes run this command two or three times before Git tells me "Everything up-to-date", so apparently it's not an exact mirror. It seems to be re-pushing tracking branches...?
$ git push --mirror
Counting objects: 42, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (30/30), done.
Writing objects: 100% (30/30), 5.09 KiB, done.
Total 30 (delta 17), reused 0 (delta 0)
To ssh://my/repo/url
c094a10..0eedc92 mybranch -> mybranch
$ git push --mirror
Total 0 (delta 0), reused 0 (delta 0)
To ssh://my/repo/url
c094a10..0eedc92 origin/mybranch -> origin/mybranch
$ git push --mirror
Everything up-to-date
What is happening, and is this a good strategy?
Edit: I don't like to use something like git bundle
or .tar.bz2
archives, because I'd like the backup to be an accessible working copy. Since my backup server is connected to the net and always on, this is a nice way to access the repository when I'm on the road.
I would say this is a perfectly acceptable strategy for backing up your repository. It should perform a push to your origin remote for every ref in the repository. Making it a complete 'mirror' of your local repository.
EDIT: I've just seen your updated description in the question. It seems git is pushing your remote ref to the remote itself along with everything else. Once the push has finished, the remote ref will be updated to reflect that you have just pushed to it. This will now be out of date with the remote repository so a further push is necessary. If this doesn't satisfy you. You can delete this remote ref with
git push :origin/mybranch
and then use
git push --all
remember that this won't push any new branches you create though.