This question uses Git 2.7.0.windows.1
, so some of the git commands might be outdated.
If my git merge
command doesn't detect a renamed file, how can I tell git to manually merge the changes in two files that are supposed to be a single file, without starting the merge over and using a lower rename threshold?
Reproduction Steps:
git init
echo "//Hello world!" > hw.h
git add . && git commit -m "Initial commit"
git checkout -b someBranch
mv hw.h hw.hpp
echo "//Foobar" > hw.hpp
git add . && git commit -m "Change hw to HPP & change content"
git checkout master
echo "//Boofar" > hw.h
git add . && git commit -m "Change content of hw"
git merge -X rename-threshold=100% someBranch
You will get merge conflicts, but no conflicted chunks. That is, the only conflict/error you should get is:
CONFLICT (modify/delete): hw.h deleted in branchB and modified in HEAD. Version HEAD of hw.h left in tree.
Automatic merge failed; fix conflicts and then commit the result.
And git status --porcelain
will show:
UD hw.h
A hw.hpp
Normally, when merging, it's ideal to set the threshold for detecting renames low enough that renames are detected. Some people recommend 5%, for example. In my case, I'm doing a massive merge (>1000 files and about 9m LOC), and I had to raise the rename threshold high enough to avoid any "false positives"; literally one percent lower and I got a huge swath of falsely-detected renames (I know, duplicated code sucks). At the value I wound up using, I get only a small handful of missed renames, which seems like a better option.
TL;DR lowering the rename threshold is not an option for me; how can I, without starting the merge over, tell git to consider hw.h
and hw.hpp
to be a single file (with conflicts), rather than two files as shown above?