I can backup my local .git by pushing it to a repository in two steps:
git push --all ~/gitrepo
git push --tags ~/gitrepo
I can back it up using git bundle.
I can back it up by simply copying the entire directory or archiving it (compressed!):
tar -zcvf gitrepo.tgz .git
And there are probably additional ways to backup an entire local .git.
The question now is whether they are really equivalent? (for example, the logs
subdirectory isn't pushed)
What are the advantages of the git push
method vs. git bundle
?
Can tar -zcvf
be considered "the perfect git backup"?
There're two ways you can backup your git repository on multiple platforms. First, you can use git remote add command, and second, you can push git bare repository into another git services.
git clone is primarily used to point to an existing repo and make a clone or copy of that repo at in a new directory, at another location. The original repository can be located on the local filesystem or on remote machine accessible supported protocols. The git clone command copies an existing Git repository.
You cannot push directly to a bundle file. A bundle file is a compressed representation of a repository, and to modify it would involve unbundling, pushing, and bundling again. One way to do this is as you said, create a new bundle every time you want to make a backup.
I use Git bundle
git bundle create /tmp/backup.git --all --tags --remotes
You can receive it as if it were a repo:
cd myworktree
git pull /tmp/backup.git
But also see
For complete backup (thing of git-rerere cache, stashes, hooks, configuration files) I suggest using rsync
rsync -hxPavilyzH --stats --delete .git/ backup@remote:/repo/mirror.git/
Alternatively:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With