Git 错过了扩展分支开发的 rebase?

发布于 2024-11-24 03:10:46 字数 566 浏览 0 评论 0原文

几个月前,我在我正在从事的一个项目中从主开发分支中分离出来。我一直在自己的实验分支上工作,但不断吸收 master 的更改以保持最新状态。每次我这样做时,我都会使用这个命令集。

git checkout master
git pull
git checkout experiment
git merge master

今天,我将我的实验分支合并回主分支。我只是确保我与 master 保持同步,并调用

git checkout master
git merge experiment

当我在 master 分支的 GitX 中查看时,它显示了一条单独的开发线,每次我从 master 拉取时都会显示一条单独的开发线,以使自己保持最新状态。这是因为当我拉取更改时我应该对 master 进行 rebase 吗?

有没有人有一个好的解决方案来解决这个问题?我想我可以将实验重新建立在主控上?但实验确实是一个分支,我想将其保留为历史上一个明显的独立分支。有没有办法让我返回并重新调整旧的有问题的合并? 正如你可能知道的那样,我对 git 还很陌生。

谢谢!

A few months ago I branched off of the master development branch in a project I'm working on. I've been working on my own experiment branch, but constantly pulled in the changes from master to keep up to date. Every time I did that I used this command set

git checkout master
git pull
git checkout experiment
git merge master

Today I went to merge my experiment branch back into master. I simply made sure I was all up to date with master, and called

git checkout master
git merge experiment

When I look in GitX at the master branch, it shows a seperate line of development for what looks like every single time that I pulled from master to keep myself up to date. Is this because I should've been rebasing master when I pulled the changes?

Does anyone have a decent solution to fix this? I guess I could rebase experiment onto master? But experiment is quite the branch, and I'd like to keep it as an obvious seperate branch in history. Is there a way for me to go back and rebase the old problematic merges?
I'm pretty new to git as you can probably tell.

Thanks!

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

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

发布评论

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

评论(1

贪恋 2024-12-01 03:10:46

确切地。

当您执行合并时,实际上您有一个提交有 2 个父项,发生的情况如下:

原始历史记录:

A <- B <- C

您更改了从跟踪存储库中提取的某些内容(X 和 Y)

A <- B <- C <- X <- Y 

(假设有人添加了 D 和 E) )

A <- B <- C <- D <- E
           ^
            \- X <- Y

然后你合并:

A <- B <- C <- D <- E <- M
           ^             /
            \- X <- Y <-/

这就是为什么你看到那些“单独的行”

在变基的情况下,它是这样的:

你从跟踪存储库中提取(假设有人添加了D和E)

A <- B <- C <- D <- E
           ^
            \- X <- Y

你变基(这意味着GIT应用你的更改X,再次是)

A <- B <- C <- D <- E <- X' <- Y'

(修订版X和Y被放弃)

我相信这是你喜欢看到的

Exactly.

When you are performing a merge, you are in fact having one commit that is having 2 parents, what is happening is like this:

original history:

A <- B <- C

you changed something (X and Y)

A <- B <- C <- X <- Y 

you pulled from tracked repository (assuming someone added D and E)

A <- B <- C <- D <- E
           ^
            \- X <- Y

and then you merged:

A <- B <- C <- D <- E <- M
           ^             /
            \- X <- Y <-/

That's why you see those "separate lines"

In case of rebase, it is something like this:

you pulled from tracked repository (assuming someone added D and E)

A <- B <- C <- D <- E
           ^
            \- X <- Y

You rebase (which means GIT applies your change X, Y again)

A <- B <- C <- D <- E <- X' <- Y'

(revision X and Y is abandoned)

which I believe is what you like to see

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