How do you get git bisect to ignore merged branches?

后端 未结 10 1253
长情又很酷
长情又很酷 2020-12-04 14:26

I\'m aware that git bisect is branch-aware by design, so that if between good commit, G, and bad commit, B, you merged in a branch, it needs to take those changes into consi

10条回答
  •  广开言路
    2020-12-04 15:00

    Björn Steinbrink's answer works great, but recently started printing this:

    hint: Support for /info/grafts is deprecated
    hint: and will be removed in a future Git version.
    hint: 
    hint: Please use "git replace --convert-graft-file"
    hint: to convert the grafts into replace refs.
    hint: 
    hint: Turn this message off by running
    hint: "git config advice.graftFileDeprecated false"
    

    Here's a more modern version of his solution using "git replace" instead of grafts:

    git rev-list --first-parent --merges --parents HEAD | \
      while read COMMIT PARENT1 PARENT2; do 
        git replace --graft $COMMIT $PARENT1; 
      done
    

    Unfortunately, it is much slower for large repos (around 3 minutes for 150k commits); git replace doesn't seem to have a bulk-mode yet. You might want to restrict the rev-list to only the commits in scope of your bisect.

    To remove the replacements when you are done, you can rm .git/refs/replace/* .

提交回复
热议问题