Git 表示从远程拉取后本地分支领先于远程

发布于 2024-09-29 08:24:44 字数 523 浏览 0 评论 0原文

如果标题不清楚,我很抱歉,但这是一个奇怪的问题。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请止步禁区 2024-10-06 08:24:44

试试这个命令:

git log origin/stage..stage

这会显示你在遥控器前面的内容。根据需要执行 git rebase origin/stage / git Push

如果没有帮助,请参阅此问题:'git pull origin mybranch' 使本地 mybranch N 次提交先于原点。为什么?

Try this command:

git log origin/stage..stage

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?

若沐 2024-10-06 08:24:44

在发生以下情况后,我现在遇到了类似的问题:

  • 我的同事推送了一个简单的提交,
  • 我拉动了该提交,我的工具已标记“提交立即合并更改”
  • 我的同事决定做一个 --amend 来更改他的原始提交,以便它变成两个不同的提交,而不是
  • 我拉动了这些更改,最终比原点提前了三个提交

我的简单解决方案是撤消这三个本地提交,为每个提交运行以下命令:

git reset --soft HEAD~1

然后 git status 告诉我有两个提交落后于原点,并且我可以像往常一样拉出这些提交。

I got the similar problem now after the following had happened:

  • My collegue pushed a simple commit
  • I pulled that commit, my tool has marked "Commit merged changed immediately"
  • My collegue decides to do an --amend to change his original commit so that it becomes two different commits instead
  • I pulled that changes, ending up being three commits ahead of origin

My simple solution was to undo these three local commits, running the following command for each commit:

git reset --soft HEAD~1

Then git status tells I am behind origin with two commits, and I can pull those commits as usual.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文