git: squash/fixup earlier commit

前端 未结 6 1168
野的像风
野的像风 2020-12-03 01:42

Suppose you have:

A-B-C

Now your build/test fails. The fix should be merged in A. My current work-flow is like this:

$ git         


        
6条回答
  •  温柔的废话
    2020-12-03 02:06

    What you are doing is dangerous if you are sharing the branch on which you are making changes with other people. In your case, you are rewriting commit A and rebasing B and C on top of the new A, which is a completely new object. Anyone who had already pulled the old A into their repositories could end up corrupting their repository as the history in your repository will have "magically" changed. Their git would have no way of knowing that the history has been rewritten.

    Because of this fact, the Git developers have intentionally not made this easy to do as you must be aware of the consequences of doing such an operation.

提交回复
热议问题