Junio C Hamano <junkio@xxxxxxx> writes: > Gerrit Pape <pape@xxxxxxxxxxx> writes: > >> Shouldn't git remove the original file after merging a commit that moved >> the file away? > > I think this has been fixed quite a while ago --- does not seem > to reproduce with the current v1.5.0-rc. Having said that, I think there is a worse problem with merge-recursive. It loses untracked files that are not involved in the merge. $ mkdir repo && cd repo $ git init-db Initialized empty Git repository in .git/ $ echo a >foo && git add foo $ git commit -a -m'add foo' Created initial commit da51b094c7c75aef4362e229975be7f376fa00cb 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 foo $ git branch b $ git mv foo bar $ git commit -a -m'move foo' Created commit 3154467cd539db7a90e04b7291442384222de4a4 2 files changed, 1 insertions(+), 1 deletions(-) create mode 100644 bar delete mode 100644 foo The 'master' branch renames 'foo' to 'bar' $ git checkout b Switched to branch "b" $ echo ttt >>foo $ git commit -a -m'change foo' Created commit eb14bff5f399b1a9ca6aa450a803833c3f7b7b3a 1 files changed, 1 insertions(+), 0 deletions(-) The 'b' branch keeps 'foo' but modifies it. $ git checkout master Switched to branch "master" $ echo frotz >foo The 'master' branch has an untracked file 'foo' now. $ git merge b 100% (5/5) done Merge made by recursive. bar | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) $ ls -a ./ ../ bar .git/ Oops. 'foo' is not involved in the merge but is lost. Sadly, a similar case was fixed in merge-resolve where our branch has already removed a file, had an untracked file of the same name in the working tree, and merging an old branch that still had that path. $ git init Initialized empty Git repository in .git/ $ echo a >foo ; echo b >bar ; git add . $ git commit -m 'initial' Created initial commit 7925ec23146d4bffa1078a2c220df2c2f9935ca8 2 files changed, 2 insertions(+), 0 deletions(-) create mode 100644 bar create mode 100644 foo $ git branch b $ rm foo ; echo ttt >>bar $ git commit -a -m 'remove foo and update bar' Created commit 7fbbec4cb0d4af95090e0ba4f1fb8c9630d8e438 2 files changed, 1 insertions(+), 1 deletions(-) delete mode 100644 foo $ git checkout b Switched to branch "b" $ echo c >baz ; git add . $ git commit -m 'side' Created commit 272ef105f43df5e3629d6915001476651cafa139 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 baz $ git checkout master Switched to branch "master" $ ls -a ./ ../ bar .git/ $ echo throw >foo $ git merge -s resolve b Trying really trivial in-index merge... fatal: Merge requires file-level merging Nope. Trying simple merge. Merge made by resolve. baz | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 baz $ ls -a ./ ../ bar baz foo .git/ $ cat foo throw Fortunately merge-recursive gets this case right, but when a rename is involved it does not. - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html