push vs. bundle vs. tar zcvf — to backup entire local .git

后端 未结 3 1828
星月不相逢
星月不相逢 2020-12-15 08:20

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

3条回答
  •  心在旅途
    2020-12-15 09:04

    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

    • How to update a git clone --mirror?
    • "fetch --all" in a git bare repository doesn't synchronize local branches to the remote ones
    • Git doesn't clone all branches on subsequent clones?

    Completeness, notes

    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:

    • Is it possible to push a git stash to a remote repository?
    • copy the rerere cache directory

提交回复
热议问题