V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
drymonfidelia
V2EX  ›  git

tar -czvf git_backup.tgz /project/.git 是备份单机不联网 git repo 的正确做法吗?

  •  
  •   drymonfidelia · Aug 18, 2024 · 2038 views
    This topic created in 621 days ago, the information mentioned may be changed or developed.
    5 replies    2024-08-18 12:26:57 +08:00
    0o0O0o0O0o
        1
    0o0O0o0O0o  
       Aug 18, 2024
    /t/1050159 这个方案我用了两个月了,我很满意,很适合协作少的场景
    Rache1
        2
    Rache1  
       Aug 18, 2024
    sagaxu
        3
    sagaxu  
       Aug 18, 2024
    打包.git 目录是 OK 的,还有其它方式也可以

    只备份 heads,tags,remote heads ,不包含未 commit 的 change ,也不包含 stash
    git bundle create /tmp/foo --all //备份
    git clone /tmp/foo repo //还原

    或者 clone 一份到别的目录,然后再打包整个目录
    git clone --mirror xxx/repo.git
    mikewang
        4
    mikewang  
       Aug 18, 2024
    备份 .git 目录是可以的,不过之前可以先缩减一下大小。比较激进的做法是:

    git reflog expire --all --expire=now
    git gc --prune=now --aggressive

    可以大幅缩小 .git 的占用空间
    zhady009
        5
    zhady009  
       Aug 18, 2024   ❤️ 2
    主机 1 上
    git bundle create myproject.bundle --all

    会输出一个 myproject.bundle 的文件,然后用 U 盘或者其他方式传输到主机上 2 执行
    git clone myproject.bundle
    或者
    git pull myproject.bundle 同步
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   947 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 18:40 · PVG 02:40 · LAX 11:40 · JFK 14:40
    ♥ Do have faith in what you're doing.