我有一个分支 - 让我们称之为“Foo” - 然后我从 Foo 分支创建 Foo2,Foo 现在是一个遗留分支 - 我当前的工作重点是 Foo2。
现在我担心我可能会忘记我正在开发 Foo2,因此我可能会执行 git push origin Foo
(尤其可能是由于 bash 的制表符补全行为)。我担心这可能会以某种方式 push 从 Foo2 到 Foo 的更改。
那么,实际会发生什么?
最佳答案
让我们检查一下the documentation for git push
。该命令的一般形式为 git push <repository> <src>:<dst>
,我们想弄清楚当 :<dst>
时会发生什么省略。
If
git push [<repository>]
without any<refspec>
argument is set to update some ref at the destination with<src>
withremote.<repository>.push
configuration variable,:<dst>
part can be omitted—such a push will update a ref that<src>
normally updates without any<refspec>
on the command line. Otherwise, missing:<dst>
means to update the same ref as the<src>
.
(我保证,我没有从 git man page generator 复制此内容。)
所以无论它做什么都将涉及确切的 <src>
您提供的,这意味着只要您不在本地 Foo
中创建更多提交分支,运行git push origin Foo
找不到任何可以推送的东西,而 Remote Foo
分支将保持不变。
关于git - 如果我在分支 "Foo2"并执行 "git push origin Foo",会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55938057/