threads / discuss / 21913

false directory/file merge conflict

Subject: false directory/file merge conflict

## tl;dr

One message between Dec 8, 2009 and Dec 8, 2009.

replies: 0people: 1as markdown or json

Jeffrey Middleton· Dec 8, 2009, 22:55 UTC · lore

When a directory (with contents) has changed into a file on one branch, and another branch attempts to merge it, there's a false conflict - the directory is processed before its contents are removed. This is particularly nasty, because "resolving" the non-existent conflict results in no changes, so future merges will fail in exactly the same way. Test script and failed merge output below.

Jeffrey
-- 8< --

rm -rf directory-file mkdir directory-file cd directory-file git init

mkdir foo echo bar > foo/bar echo bas > foo/baz git add foo/bar foo/baz git commit -m "check in files"

git branch foo_unchanged

git rm -r foo echo foo > foo git add foo git commit -m "foo changes from directory to file"

git checkout foo_unchanged echo foobar > foobar git add foobar git commit -m "make a separate change"

git merge master
-- 8< --

CONFLICT (directory/file): There is a directory with name foo in HEAD. Adding foo as foo~master Removing foo/bar Removing foo/baz Automatic merge failed; fix conflicts and then commit the result.

← back to recent threads