我有两个分支(本地和github上)。 我将它们称为BranchA和BranchB。 我在BranchA中有提交c1、c2和c3。 我只有c1的BranchB。 这两个分支都已经更新到github,我可以检查BranchA有c1、c2和c3,而BranchB只有c1。
我想从本地的BranchA推送到远程的BranchB。为了做到这一点,我尝试:
git push origin refs/heads/BranchA:refs/remotes/origin/BranchB
当我这样做时,我得到了一个奇怪的输出:
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/<username>/<repo>.git
<hash> BranchA -> origin/BranchB
当我访问Github时,我发现BranchB没有更新,仍然只有c1。然后,如果我再次运行命令,它会返回一切都是最新的。
这让我感到困惑,但更糟糕的是,当我尝试执行不带完整引用的命令时,就像这样:
git push origin BranchA:BranchB
...它起作用了。
我对此非常困惑。我搜索了一下,认为使用完整的引用(例如/refs/heads/)不会有任何问题。
为什么会发生这种情况?当我指定完整的分支名称时,它不应该起作用吗?