Git rebase交互编辑合并功能分支? [英] Git rebase interactive edit for merged feature branches?

查看:132
本文介绍了Git rebase交互编辑合并功能分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下情况下会发生什么情况:


  • 有一个无限生命线的主分支

  • 新分支是为特性创建的,并在完成时与主合并。该分支被删除后缀



在某些时候,我需要对已被视为已关闭的功能进行更改(它已合并到master和删除)

$ $ p $ code $ X --- ---(功能(删除分支)
/ \
/ \
a --- --- --- M master

什么我做的是:

  git rebase --interactive X 

在源代码中进行了修改并修改了提交X.我希望图表保持不变,但是得到了如下所示的结果:

  X ---  - (功能(删除分支)
/ \
/ M
/ /
/ /
a --- --- --- X master

提交的编辑是否在合并之间传播?与现有将来提交的潜在冲突如何?


X 提交,因为在默认情况下,rebase不保留合并。如果您想保留合并,您需要使用 - preserve-merges 标志,或者 -p

  git rebase -i -p< base-commit> 

请注意,交互式保留合并在您对提交进行重新排序时无法正常工作否则可以一起使用它们:


- preserve-merges <$ c $表示的待办事项列表c> - interactive 不
表示修订图形的拓扑。编辑提交并改写
提交消息应该可以正常工作,但尝试对提交进行重新排序往往导致
产生违反直觉的结果。

另外,您确定 X 是您想要使用的基本提交吗?如果你想修改 X ,我认为你应该选择 a 作为基础:

  git rebase -i -pa 


What will happen in the following scenario:

  • There is a master branch with endless lifeline
  • New branches are created for features and merged with master when finished. The branch is afterwords deleted

At some point i needed to do a change in the feature that was already considered closed (it was merged into master and deleted)

      X --- --- (feature (branch deleted)
     /         \                
    /           \              
   a --- --- --- M master

What I did was:

git rebase --interactive X

Did the changes in the source and amended the commit X. I was hoping to have the graph unchanged but got something like:

        X --- -(feature (branch deleted)
       /      \
      /        M
     /        /
    /        /                 
   a --- --- --- X master

Does the editing of commits spread between merges? What about potential conflicts with existing "future" commits?

解决方案

Your new commit graph has another X commit because rebase does not preserve merges by default. If you wanted to preserve merges, you need to use the --preserve-merges flag, or -p for short:

git rebase -i -p <base-commit>

Note that preserving merges interactively does not work correctly when you reorder commits. It's OK to use them together otherwise:

The todo list presented by --preserve-merges --interactive does not represent the topology of the revision graph. Editing commits and rewording their commit messages should work fine, but attempts to reorder commits tend to produce counterintuitive results.

Also, are you sure that X was the base commit you wanted to use? If you wanted to amend X, I think you should have chosen a as the base instead:

git rebase -i -p a

这篇关于Git rebase交互编辑合并功能分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆