如何通过更改提交从分支进行rebase?

时间:2016-06-26 08:04:22

标签: git

最初我是这样开始的:

Branch A:    
  Commit A1  
  Commit M9

Branch B:   
  Commit B1  
  Commit M9

然后我做了:

git checkout B
git rebase A

我最终得到了:

Branch A:    
  Commit A1
  Commit M9

Branch B:   
  Commit B1  
  Commit A1
  Commit M9

然后我做了:

git checkout A
// then I modified the branch and then I did
git commit -a --amend

现在我的分支机构的状态是

Branch A:    
  Commit A1
  Commit M9

Branch B:   
  Commit B1  
  Commit A1
  Commit M9

Note that now Commit A1 is actually different in both branches.

如何使用Branch B中的新Commit A1更新Branch A

1 个答案:

答案 0 :(得分:0)

你可以做:

git checkout B
git rebase -i A

当文本编辑器打开时,删除与旧版A1'相对应的行。提交(在分支B中)。

通常情况下,您不应该有冲突处理,除非B1基于您在修改中更改的同一段代码(但它应该更容易处理)。

相关问题