Git bisect with merged commits

后端 未结 4 707
走了就别回头了
走了就别回头了 2021-02-02 06:17

I have a history that looks like this:

* 3830e61 Add data escaping.              (Bad)
* 0f5e148 Improve function for getting page template.
*   aaf8dc5 Merge br         


        
4条回答
  •  鱼传尺愫
    2021-02-02 06:46

    Warning: the git bisect section regarding "Automatically bisect with temporary modifications" has been updated with Git 2.25 (Q1 2020).

    (And git bisect --first-parent is available with Git 2.29+ -- Q4 2020)

    It involves the step where you reapply the commit you are testing on top of your relevant master commit (which was ea3d736 in the OP's case)

    The "git merge --no-commit" needs "--no-ff" if you do not want to move HEAD, which has been corrected in the manual page for "git bisect".

    See commit 8dd327b (28 Oct 2019) by Mihail Atanassov (matana).
    (Merged by Junio C Hamano -- gitster -- in commit fac9ab1, 01 Dec 2019)

    Documentation/git-bisect.txt: add --no-ff to merge command

    Signed-off-by: Mihail Atanassov
    Reviewed-by: Jonathan Nieder

    The hotfix application example uses git merge --no-commit to apply temporary changes to the working tree during a bisect operation.

    In some situations this can be a fast-forward and merge will apply the hotfix branch's commits regardless of --no-commit (as documented in the git merge manual).

    In the pathological case this will make a [git bisect](https://git-scm.com/docs/git-bisect) run invocation loop indefinitely between the first bisect step and the fast-forwarded post-merge HEAD.

    Add --no-ff to the merge command to avoid this issue.

    git merge mentions indeed:

    Note that fast-forward updates do not create a merge commit and therefore there is no way to stop those merges with --no-commit.

    Thus, if you want to ensure your branch is not changed or updated by the merge command, use --no-ff with --no-commit.

提交回复
热议问题