【问题标题】:How to change a git repository cloned with --bare to match one cloned with --mirror?如何更改使用--bare 克隆的git 存储库以匹配使用--mirror 克隆的git 存储库?
【发布时间】:2012-09-03 06:34:50
【问题描述】:

这个问题与git - how to mirror file from other repoHow do I update my bare repo?不一样

由于使用--mirror 克隆的存储库是一个裸存储库,我可以使使用--bare 克隆的存储库与使用--mirror 克隆的存储库一样吗?可以通过简单的修改配置文件来完成吗?

如果没有,是否有其他方法可以将裸存储库转换为镜像存储库?

另一个问题,为什么我不能在镜像仓库中使用 git push --all ,而这个命令可以在裸仓库中运行?

【问题讨论】:

  • 您可以在任何编辑器中轻松编辑配置文件。只需按照它们在镜像 repo (+refs/*:refs/*) 中的方式引用分支,删除远程跟踪分支(从打包引用和 refs/remote/*/* 中),添加mirror=true,然后重新运行git fetch
  • @fork0 这个微不足道的操作似乎行不通...
  • 究竟是什么不起作用?错误信息? (顺便说一句,我没有提到要在哪个部分添加mirror=true。它是[core])。

标签: git version-control git-push


【解决方案1】:

现在:

git remote add --mirror=fetch origin <url>

然后

git fetch

【讨论】:

    【解决方案2】:

    要将使用git clone --bare 克隆的存储库更改为与git clone --mirror 匹配的存储库,请执行以下操作:

    $ git config remote.origin.fetch "+refs/*:refs/*" 
    $ git config remote.origin.mirror true
    

    然后做一个git fetch,一切都应该是最新的。

    【讨论】:

      【解决方案3】:

      如果您使用git clone --mirror 克隆了您的存储库,那么在default matching push policy 之后的git push --all 会将所有本地分支推送到远程存储库。

      但如果您的远程仓库已作为远程参考添加到您的本地仓库(即您的本地仓库已从另一个远程仓库克隆),那么git push --all secondRemoteRepo 将找不到很多要推送到的匹配分支,除非您先获取这些分支。
      所以这应该有效:

      git fetch secondRemoteRepo
      git push --all secondRemoteRepo
      

      【讨论】:

        猜你喜欢
        • 2017-08-07
        • 1970-01-01
        • 2017-03-04
        • 2016-08-15
        • 2013-07-14
        • 1970-01-01
        • 2018-06-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多