Git 错过了扩展分支开发的 rebase?
几个月前,我在我正在从事的一个项目中从主开发分支中分离出来。我一直在自己的实验分支上工作,但不断吸收 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确切地。
当您执行合并时,实际上您有一个提交有 2 个父项,发生的情况如下:
原始历史记录:
您更改了从跟踪存储库中提取的某些内容(X 和 Y)
(假设有人添加了 D 和 E) )
然后你合并:
这就是为什么你看到那些“单独的行”
在变基的情况下,它是这样的:
你从跟踪存储库中提取(假设有人添加了D和E)
你变基(这意味着GIT应用你的更改X,再次是)
(修订版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:
you changed something (X and Y)
you pulled from tracked repository (assuming someone added D and E)
and then you merged:
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)
You rebase (which means GIT applies your change X, Y again)
(revision X and Y is abandoned)
which I believe is what you like to see