git merge: Removing files I want to keep!

This is an interesting issue. Because you deleted the file after BranchA was created, and then are merging master into BranchA, I’m not sure how Git would be able to realize there is a conflict.

After the bad merge you can undo, and then re-merge, but add back the file:

git checkout HEAD@{1} .
git merge --no-commit master
git checkout master test.txt
git add test.txt
git commit

Leave a Comment