{"thread":{"id":"28901","subject":"uncommitted changes in a renamed directory are clobbered on merge","startedAt":"2011-11-10T05:28:59Z","lastAt":"2011-11-10T05:28:59Z","messageCount":1,"participants":["Paul Grayson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"179235","messageId":"CAFk1Bv98FR3a=DyhoEjRDv-Eh5iwoJSe-ZxKPDxcQbv3q7E=0A@mail.gmail.com","threadId":"28901","inReplyTo":null,"subject":"uncommitted changes in a renamed directory are clobbered on merge","fromName":"Paul Grayson","fromEmail":"pdg@alum.mit.edu","sentAt":"2011-11-10T05:28:59Z","receivedAt":"2011-11-10T05:28:59Z","isPatch":false,"sender":{"key":"pdg@alum.mit.edu","avatar":null},"body":"Hello,\n\nWhile merging with uncommitted changes is strongly discouraged, Git\ngenerally tries to not overwrite your work without warning.  However,\nthere are some situations where Git silently erases uncommitted\nchanges.  Specifically, it seems that if you rename a directory on one\nbranch, make uncommitted changes to files within that branch, then\nmerge in another branch, files that would conflict get replaced by the\nversion on the other branch.  We have observed this on Git versions\n1.7.5.4 and 1.7.7.3.\n\nI have placed a script demonstrating this problem at\nhttps://gist.github.com/1354160\n\nHere is a shell transcript showing what it looks like:\n\ngitbug$ git init single\nInitialized empty Git repository in /home/paul/gitprojects/gitbug/single/.git/\ngitbug$ cd single/\ngitbug/single$ mkdir test\ngitbug/single$ echo \"hi\" > test/test.txt\ngitbug/single$ git add .\ngitbug/single$ git commit -am \"initial revision\"\n[master (root-commit) 8be9a1e] initial revision\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 test/test.txt\ngitbug/single$ git checkout -b branch1\nSwitched to a new branch 'branch1'\ngitbug/single$ git mv test/ test2\ngitbug/single$ git commit -am \"renamed test to test2\"\n[branch1 80d497c] renamed test to test2\n 1 files changed, 0 insertions(+), 0 deletions(-)\n rename {test => test2}/test.txt (100%)\ngitbug/single$ git checkout master\nSwitched to branch 'master'\ngitbug/single$ echo \"change on master\" >> test/test.txt\ngitbug/single$ git commit -am \"made a change on master\"\n[master 51d3a75] made a change on master\n 1 files changed, 1 insertions(+), 0 deletions(-)\ngitbug/single$ git checkout branch1\nSwitched to branch 'branch1'\ngitbug/single$ echo \"change on branch1\" >> test2/test.txt\ngitbug/single$ git merge master\nAuto-merging test2/test.txt\nMerge made by recursive.\n test2/test.txt |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\ngitbug/single$ cat test2/test.txt\nhi\nchange on master\ngitbug/single$\n\nI expected the merge to fail as it usually does when there is a\nconflict with uncommitted changes.  Instead, it silently deleted the\nchanges in test.txt.\n\nOne of our developers just lost a few hours of work to this bug.  Please fix!\n\nSincerely,\nPaul Grayson\n"}]}