Git 表示从远程拉取后本地分支领先于远程
如果标题不清楚,我很抱歉,但这是一个奇怪的问题。
我 git checkout
到我的“stage”分支,并 git pull
获取我合作伙伴的最新更改(他昨晚将其推送到远程存储库上的“stage”分支),果然,它们合并到我本地的“舞台”分支。 git log
显示他昨晚执行的五次提交。
然后我切换到主分支以从存储库中提取它,因为他告诉我他在测试后将这些更改合并到主分支。但是当我 git checkout stage 回到我的“stage”分支时,它说我领先于远程分支 5 个提交。我 git log origin/stage ,它没有显示我刚刚从该存储库(该项目中唯一的远程存储库)中提取的五个提交。 git log stage 显示了我本地“stage”分支上的五个提交,因此我不知道远程分支如何在为我提供合作伙伴的最新提交后立即返回到过去。
我在这方面还很陌生,所以我会感谢您对我的耐心,因为我仍在努力掌握 DCVS,而且很可能我只是误解了一些非常基本的东西。
I’m sorry if the title isn’t clear, but this is a weird problem.
I git checkout
to my "stage" branch and git pull
to get my partner’s latest changes (which he pushed last night to the "stage" branch on the remote repository), and sure enough, they merge to my local "stage" branch. git log <branch>
shows five commits he performed last night.
I then switch over to the master branch to pull that from the repo because he told me he merged those changes to the master branch after testing them. But when I git checkout stage
to get back to my "stage" branch it says I’m ahead of the remote branch by 5 commits. I git log origin/stage
and it shows none of the five commits I just pulled from that repository (the only remote repository on this project). git log stage
shows the five commits on my local "stage" branch, so I’m at a loss at how the remote branch could have gone back in time immediately after serving me my partner’s latest commits.
I’m pretty new at this, so I’ll appreciate your patience with me, as I’m still trying to grasp DCVSs and there’s a good chance I’m simply misunderstanding something really basic.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个命令:
这会显示你在遥控器前面的内容。根据需要执行
git rebase origin/stage
/git Push
。如果没有帮助,请参阅此问题:'git pull origin mybranch' 使本地 mybranch N 次提交先于原点。为什么?
Try this command:
This show you what you are ahead of the remote. Do a
git rebase origin/stage
/git push
as appropriate.If it doesn't help, see this question : 'git pull origin mybranch' leaves local mybranch N commits ahead of origin. Why?
在发生以下情况后,我现在遇到了类似的问题:
我的简单解决方案是撤消这三个本地提交,为每个提交运行以下命令:
然后 git status 告诉我有两个提交落后于原点,并且我可以像往常一样拉出这些提交。
I got the similar problem now after the following had happened:
My simple solution was to undo these three local commits, running the following command for each commit:
Then git status tells I am behind origin with two commits, and I can pull those commits as usual.