【问题标题】:Difference between git push -f vs git push origin +mastergit push -f 与 git push origin +master 的区别
【发布时间】:2017-10-11 13:54:46
【问题描述】:

假设我想通过git reset –hard HEAD~从本地和远程存储库中删除最后一次提交 然后 git push -fgit push origin +master

因为我发现这两种方法都用于强制推送。以上两个推送命令之间是否有任何区别或它们的工作方式相同?

【问题讨论】:

  • 没有区别。 git push -f origin branch1 branch2 等价于 git push origin +branch1 +branch2

标签: git repository git-push


【解决方案1】:

请参阅手册:-f 也推翻了--force-with-lease,另外:-f 适用于所有您推送的 refs,以防您同时推送多个。 p>

【讨论】:

  • 我的意思是什么时候用-f或者什么时候用+branch
  • 如果你只推送一个分支并且偶尔想强制推送它,+ 表示法就可以了。不过,这两个选项都不是您想要默认使用的;小心使用。
猜你喜欢
  • 1970-01-01
  • 2015-12-08
  • 2017-09-21
  • 2021-04-13
  • 2012-09-09
  • 2020-07-30
  • 2023-02-02
  • 2015-07-03
  • 1970-01-01
相关资源
最近更新 更多