How can I ignore a directory when doing a Git bise

2019-08-15 10:40发布

问题:

I have a production build directory which often conflicts when merging branches. That's a separate issue. I need to find a problem in the commit history using Git bisect, but I get the following error:

Bisecting: a merge base must be tested

error: Untracked working tree file 'problem_directory/filename.ext' would be overwritten by merge.

Can I ignore problem_directory during the bisect process?

回答1:

Build directories should not be checked in for exactly the reason you're encountering.

Consider adding it to .gitignore and using a tool like BFG Repo Cleaner to remove it from history. Then it will not be a problem for your bisects.

Alternatively, clean up the build directory when your testing is done. If you're using git bisect run, put make clean or the equivalent in your build system at the end of the script.