Search code examples
gitgit-bisect

Is `git reset --hard` required before mark the current commit as good or bad during bisect?


In my current workflow, I'm updating/rebasing an ancient patch to work against recent versions of a projetct.

In my current workflow, I use git bisect to find the latest commit which can be used to cleanly apply the patch.

To check if the patch can be cleanly applied, I need to patch the files and check the exit status. This procedure changes the working directory, which is no longer clean.

Before apply the current commit as good or bad, I always use git reset --hard, but this task is annoying. Is it required or git bisect will take care of it for me?


Solution

  • It is a good idea to do a git reset --hard as you have been doing.

    If the local changes are not affected by the checkout then it does not matter, they will just "ride along with you".

    However if your local changes would be overwritten by a checkout it will create an error

    $ git bisect good
    Bisecting: 2 revisions left to test after this (roughly 1 step)
    error: Your local changes to the following files would be overwritten by checkout:
            README
    Please, commit your changes or stash them before you can switch branches.
    Aborting