Git镜子没有强制推动

时间:2013-02-01 09:58:38

标签: git

是否有可能以某种方式设置一个git存储库,该存储库可以像往常那样工作 - 用于拉入它的镜像,但是当将推送到另一个存储库时没有强制执行?

3 个答案:

答案 0 :(得分:4)

您可以添加--no-force来禁用强制行为,如下所示:

git push --mirror --no-force

这将禁用非快进更新(使用git 1.8.0.2测试)。

答案 1 :(得分:3)

  

我想做一个git push --mirror,如果需要非快速更新,它将会失败。

如果上游repo的配置设置为receive.denyNonFastForwards true,则git push --mirror应该失败:

git config man page

receive.denyNonFastForwards
  

如果设置为truegit-receive-pack将拒绝不是快进的参考更新。
  使用此选项可以通过推送阻止此类更新,即使强制推送   初始化共享存储库时会设置此配置变量。

这意味着你不必“重现”--mirror“所做的事情:你可以简单地使用它,如果涉及任何非快速合并,仍然会使该推送失败。

答案 2 :(得分:1)

  

有没有办法重现 - 镜像与其他选项有什么关系?

使用多次推送可以执行一些镜像操作:

git push <remote> --all  # push all branches
git push <remote> --tags # push all tags
git push <remote> refs/remotes/* #push the remote refs