git rebase -i -autosquash conflict

前端 未结 3 2118
一生所求
一生所求 2021-02-10 06:10

git is giving me a major headache when using --fixup and --autosquash. I would like to give two examples, one working perfectly fine and the other being a mess. (git version 2.

3条回答
  •  伪装坚强ぢ
    2021-02-10 07:09

    I think that the problem is the context of the changes. Look at this commit:

    $ git show c3d3db7
    diff --git a/test.file b/test.file
    index 7a103db..8c8e69a 100644
    --- a/test.file
    +++ b/test.file
    @@ -1,3 +1,3 @@
     1
     2
    -This is a BUG
    +This is NOT a BUG
    

    And you want to apply this patch to the file with contents:

    1
    This is a BUG
    

    See? The patch does not apply, because the context does not match. So a conflict arises and you have to fix it manually.


    When you have the bugger line split in two, the patch is something like:

    diff --git a/test.file b/test.file
    --- a/test.file
    +++ b/test.file
    @@ -1,3 +1,3 @@
     1
     2
     This is
    -a BUG
    +NOT a BUG
    

    And the file is:

    1
    This is
    a BUG
    

    Now, while the match is not perfect, at least the first unmodified line of the context matches, so the merge may continue.

提交回复
热议问题