来自多个分支的Git rebase没有得到改变 [英] Git rebase from multiple branches not getting changes
问题描述
在master分支中,我为一个项目创建了一个分支topicA,这个分支只是原始文件的子集,并添加了一些新文件。为此,我创建了分支,删除了不需要的文件,添加了一些新文件并提交。
然后我创建了一个特性分支topicB并做了一些更改。 E - H - I topicA
/
/ K - L - M topicB
/
A - B - C - D - F - J - N master
我希望将topicB中的更改应用于topicA。结果树如下所示:
E - H - I topicA
/
K- -L - M topicB
/
A - B - C - D - F - J - N master
我一直在尝试为此使用rebase,但一直无法获得理想的结果。
git checkout topicA
git rebase topicB
在合并和我解决的一些冲突中,但并非来自topicB的所有更改都出现在新的topicA中。
我也试过了
git rebase --onto topicA master topicB
认为这将把topicB中的变化应用到topicA中,并且master是共同的祖先,但是这最终会在topicB分支中发生变化。
After我将主题与主题B的变化重新组合起来n能够将主题中的topicA重定位为继续获取对topicA重要的文件的更改。
是否有可能从master分支,然后从另一个分支进行rebase也从主人分支?
我使用rebase错了吗?
合并对这个用例更好吗?
$ b $ p感谢
$ b
更新 strong>
由@VonC描述的rebase有效,现在我有一棵树:
E - H- -I topicA
/
K - L - M - O topicB
/
A - B - C - D - F - J - N master
当我尝试从topicB重新转换topicA以获得新的更改时,我运行
git checkout topicA
git rebase topicB
但是它要求我解决冲突,我已经决定重新定义topicA并将它分解为M.如何在不处理所有冲突的情况下将topicA转换为topicB'O'我已经解决了?
rebase --onto
应该使用从 topicA
创建的确切提交:
git rebase --onto topicB D topicA
请参阅该示例用于说明。
这会得到:
E' - H' - I'topicA
/
K - L - M topicB
/
A - B - C - D - F - J - N master
然后,是的,您可以在 master
:
git checkout topicA
git rebase master
From the master branch I created a branch "topicA" for a project that is just a subset of the original files with a few new files added. To do this I created the branch, deleted the unneeded files, added some new files and committed.
I then created a feature branch "topicB" and made some changes.
E--H--I topicA
/
/ K--L--M topicB
/ /
A--B--C--D--F--J--N master
I want the changes in "topicB" to be applied to "topicA". The resulting tree would look like:
E--H--I topicA
/
K--L--M topicB
/
A--B--C--D--F--J--N master
I've been trying to use rebase for this but have been unable to get the desired result.
git checkout topicA
git rebase topicB
This is resulting in a merge and some conflicts I resolved, but not all of the changes from topicB are present in the new topicA.
I also tried
git rebase --onto topicA master topicB
thinking that this would apply the changes from topicB into topicA with master being the common ancestor, but this ended with me being in the topicB branch with changes.
After I rebase master with the changes from topicB I would like to then be able to rebase topicA from master to continue to get changes to the files important to topicA.
Is it possible to branch from master and then rebase from another branch that was also branched from master? Am I using rebase wrong? Would merge be better for this use case?
Thanks
Update The rebase described by @VonC works and now I have a tree like:
E--H--I topicA
/
K--L--M--O topicB
/
A--B--C--D--F--J--N master
When I try to rebase topicA from topicB again to get the new change I ran
git checkout topicA
git rebase topicB
But it is asking me to resolve conflicts I've already resolved to rebase topicA and get it branched off of M. How do rebase topicA to topicB 'O' without dealing with all of the conflicts I've already resolved?
The rebase --onto
should use the exact commit from which topicA
was created:
git rebase --onto topicB D topicA
See that example for illustration.
That would get:
E'--H'--I' topicA
/
K--L--M topicB
/
A--B--C--D--F--J--N master
Then, yes, you can rebase topicA
on top of master
:
git checkout topicA
git rebase master
这篇关于来自多个分支的Git rebase没有得到改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!