git推到一个是1个提交的存储库

发布于 2025-01-19 22:49:34 字数 558 浏览 0 评论 0原文

我正在开发一个存储库,可以说我已经创建了一个提交“B”。 提交“A”是起源/主。它看起来像这样:

A -------------------- B
(origin/master)      (HEAD)

但是其他人在我之前推送了一个提交(将其视为“Z”),并且不知道我在 B 之上创建了另一个提交,将其视为“C”。现在看起来是这样的。

      (origin/master)
A --------- Z
 \
  \
   -------- B -------- C
                      (HEAD)

如何首先拉取提交“Z”,然后推送本地提交。我可以确认 (Z) 和 (B, C) 是不相关的文件更改。我希望它们最终看起来像这样:

A -------- Z -------- B -------- C
                          (HEAD, origin/master)

我尝试过 git pull --rebase ,但没​​有用。让我知道如何重新启用它

I am working on a repository, where lets say I have created a commit 'B'.
Commit 'A' is the origin/master. It looks like this:

A -------------------- B
(origin/master)      (HEAD)

But someone else pushed a commit (consider it as 'Z') before me, and without knowing that I created another commit on top of B, consider it as 'C'. It looks like this now.

      (origin/master)
A --------- Z
 \
  \
   -------- B -------- C
                      (HEAD)

How can I first pull the commit 'Z' and then push my local commits. I can confirm (Z) and (B, C) are unrelated file changes. I want them to eventually look like this:

A -------- Z -------- B -------- C
                          (HEAD, origin/master)

I have tried git pull --rebase but no use. Let me know how can I re-enable it

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

三生池水覆流年 2025-01-26 22:49:34

实际上,git pult -rebase应该在此处工作,以达到您想要的a -z -z -b - c分支。您也可以尝试明确的重置操作,然后进行推动:

# from local master
git fetch origin
git rebase origin/master
git push origin master

Actually, git pull --rebase should be working here to arrive at the A -- Z -- B -- C branch you want. You could also try an explicit rebase operation followed by a push:

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