V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
drymonfidelia
V2EX  ›  git

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

  •  
  •   drymonfidelia · 42 天前 · 1116 次点击
    这是一个创建于 42 天前的主题,其中的信息可能已经有所发展或是发生改变。
    5 条回复    2024-08-18 12:26:57 +08:00
    0o0O0o0O0o
        1
    0o0O0o0O0o  
       42 天前
    /t/1050159 这个方案我用了两个月了,我很满意,很适合协作少的场景
    Rache1
        2
    Rache1  
       42 天前
    sagaxu
        3
    sagaxu  
       42 天前
    打包.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  
       42 天前
    备份 .git 目录是可以的,不过之前可以先缩减一下大小。比较激进的做法是:

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

    可以大幅缩小 .git 的占用空间
    zhady009
        5
    zhady009  
       42 天前   ❤️ 2
    主机 1 上
    git bundle create myproject.bundle --all

    会输出一个 myproject.bundle 的文件,然后用 U 盘或者其他方式传输到主机上 2 执行
    git clone myproject.bundle
    或者
    git pull myproject.bundle 同步
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1282 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 17:25 · PVG 01:25 · LAX 10:25 · JFK 13:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.