Behaviour is normal, because you renamed the file without git mv
; git correctly detected file rename, but did not commit deletion of old file, so you have both files now after merge.
Using git mv
, or mv
followed by git rm oldfile
it correctly leads to a merge conflict.
Initialized empty Git repository
$ echo "hello" > hello.txt
$ git add hello.txt && git commit -m "first"
[master (root-commit) 708ec5f] first
1 file changed, 1 insertion(+)
create mode 100644 hello.txt
$ git branch mybranch
$ git mv hello.txt hello2.txt
$ git commit -m "renamed"
[master 00c68ed] renamed
1 file changed, 0 insertions(+), 0 deletions(-)
rename hello.txt => hello2.txt (100%)
$
$ git checkout mybranch
Switched to branch 'mybranch'
$ mkdir test
$ git mv hello.txt test
$ git commit -m "moved"
[mybranch 044e091] moved
1 file changed, 0 insertions(+), 0 deletions(-)
rename hello.txt => test/hello.txt (100%)
$ git checkout master
Switched to branch 'master'
$ git merge mybranch
CONFLICT (rename/rename): Rename "hello.txt"->"hello2.txt" in branch "HEAD" rename "hello.txt"->"test/hello.txt" in "mybranch"
Automatic merge failed; fix conflicts and then commit the result.