【问题标题】:How can I keep a git mirror in sync (including deleting branches)?如何保持 git 镜像同步(包括删除分支)?
【发布时间】:2011-10-27 11:12:47
【问题描述】:

我已经使用git clone --mirror 克隆了一个 git 存储库,并且我想保持镜像是最新的。到目前为止,我一直在使用git fetch --all,但我注意到在原始存储库中删除的分支不会在镜像存储库中删除。我查看了How to update a git clone --mirror?,但我尝试使用git remote update 似乎没有工作 - 在原始存储库中删除的分支在镜像存储库中仍然可见。

【问题讨论】:

    标签: git synchronization mirror


    【解决方案1】:

    使用git remote prune remoteName 删除远程分支。

    您也可以将--prune 标签添加到git remote update

    【讨论】:

    • 完美运行,谢谢!仅供参考,该消息尚不清楚,但它完全符合问题中的要求:它删除了远程端不再存在的本地引用
    • @Andy 更新会保留我的更改还是会覆盖某些内容?
    • 更新不应更改您计算机上的任何提交。它所做的只是为您的远程存储库上的分支获取新的更新。
    【解决方案2】:

    我更进一步,全局配置:

    git config --global fetch.prune true
    

    【讨论】:

      猜你喜欢
      • 2015-04-20
      • 1970-01-01
      • 2022-11-27
      • 2018-02-06
      • 1970-01-01
      • 2013-05-11
      • 2014-10-29
      • 1970-01-01
      • 2013-11-14
      相关资源
      最近更新 更多