git - git push --force 与 git push 非快进更新之间的区别

标签 git

假设我跑

git push --force origin master:master(强制更新)

在另一个地方

git push origin +master:master(非快进更新)

这两个是一样的吗?这 2 个行为不同的任何场景?

最佳答案

它们是相同的。来自docs :

All of the rules described above about what’s not allowed as an update can be overridden by adding an the optional leading + to a refspec (or using --force command line option).

但是,也许很明显,--force 适用于所有被推送的内容,而 + 仅适用于以 + 为前缀的 refspec >(在本例中为 master)。在您问题的两个命令中,这没有区别,因为它们中只有一个 refspec。

关于git - git push --force 与 git push 非快进更新之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54111065/

相关文章:

git - 在 Visual Studio 2013 中使用 Git 时 Sync 如何工作?

git - 将本地存储库分支重置为就像远程存储库 HEAD

Git 工作流和发布分支 : Many, 一个,还是一个?

git - 如何使用 git 跟踪主目录中的 "dot"配置文件?

git - Heroku + Github 部署策略

ruby - 通过 REST API 或 Ocktokit (Ruby) 从 GitHub 获取文件的最聪明的方法

java - 从 java 运行终端命令(使用 Eclipse)

git:我可以添加一个目录,但在提交时我得到 "nothing to commit"

git - git 中的 svn revert 等价物是什么?

git - 为什么需要在 GitFlow 中开发分支