如何在Git中重新加入父项 [英] how to re-parent in Git
问题描述
在每种情况下,什么非交互式git命令实现了从before到after的变化?
1a。重新注册我
之前:
A --- B --- C --- D
After:
C'--- D'
/
A --- B
1b。重新注册II
之前:
C --- D
/
A --- B
后:
C
/
A --- B --- D'
<1c。重新注册III
之前:
C
/
A --- B --- D
之后:
C --- B'--- D'
/
A
code>
这些都看起来像 git rebase --onto
。
1a。重新注册我之前
之前: --- C --- D
后:
C'--- D'
$ p $ >
/
A --- B
$ b <$>设置分支来标记特定的提交,然后重新绑定到。 c $ c> git checkout -b ex1a -b B
git checkout -b ex1a -d D
git checkout -b ex1a -a A
git rebase - ex1a -a ex1a -b ex1a-d
1b。重新注册II
之前:
C --- D
/
A --- B
之后:
C
/
A --- B --- D'
创建类似以上的分支:
git rebase --onto ex1b -b ex1b -c ex1b-d
。
1c。重新注册III
之前:
C
/
A --- B --- D
之后:
C --- B'--- D'
/
A
再次使用分支,但现在只需
git rebase ex1c -c ex1c-d
。What non-interactive git command(s) achieve the change from Before to After in each case?
1a. re-parenting I
Before:
A---B---C---D
After:
C'---D' / A---B
1b. re-parenting II
Before:
C---D / A---B
After:
C / A---B---D'
1c. re-parenting III
Before:
C / A---B---D
After:
C---B'---D' / A
解决方案These all look like applications of
git rebase --onto
.1a. re-parenting I
Before:
A---B---C---D
After:
C'---D' / A---B
Set up branches to label the particular commits and then rebase onto.
git checkout -b ex1a-b B
git checkout -b ex1a-d D
git checkout -b ex1a-a A
git rebase --onto ex1a-a ex1a-b ex1a-d
1b. re-parenting II
Before:
C---D / A---B
After:
C / A---B---D'
Creating branches similar to above:
git rebase --onto ex1b-b ex1b-c ex1b-d
.1c. re-parenting III
Before:
C / A---B---D
After:
C---B'---D' / A
Again with the branches, but now just
git rebase ex1c-c ex1c-d
.这篇关于如何在Git中重新加入父项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!