git - 如果我在分支 "Foo2"并执行 "git push origin Foo",会发生什么?

标签 git

我有一个分支 - 让我们称之为“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> with remote.<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/

相关文章:

git - 为什么 Git 只是在没有 --force 标志的情况下执行强制更新?

git - 对于git,如何通过一个命令在一个子目录中暂存所有的更改,包括删除?

linux - 私有(private) Git repo - 在 pull 时卡住

git - 我怎样才能 git pull 覆盖更改

git - 如何使 git LFS 不适用于子目录

git - 如何在 Go 中禁用 git clone 的凭据提示?

git - 如何在团队成员之间共享大型 git merge

git - 使用 Git 时如何在 Visual Studio 中刷新分支(本地/远程)?

git - 如何从 TFS 获取类似 git 的统计信息

git - 如何设置 GitBlit 存储库以防止用户推送?