uncommitted changes in a renamed directory are clobbered on merge

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

While merging with uncommitted changes is strongly discouraged, Git
generally tries to not overwrite your work without warning.  However,
there are some situations where Git silently erases uncommitted
changes.  Specifically, it seems that if you rename a directory on one
branch, make uncommitted changes to files within that branch, then
merge in another branch, files that would conflict get replaced by the
version on the other branch.  We have observed this on Git versions
1.7.5.4 and 1.7.7.3.

I have placed a script demonstrating this problem at
https://gist.github.com/1354160

Here is a shell transcript showing what it looks like:

gitbug$ git init single
Initialized empty Git repository in /home/paul/gitprojects/gitbug/single/.git/
gitbug$ cd single/
gitbug/single$ mkdir test
gitbug/single$ echo "hi" > test/test.txt
gitbug/single$ git add .
gitbug/single$ git commit -am "initial revision"
[master (root-commit) 8be9a1e] initial revision
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 test/test.txt
gitbug/single$ git checkout -b branch1
Switched to a new branch 'branch1'
gitbug/single$ git mv test/ test2
gitbug/single$ git commit -am "renamed test to test2"
[branch1 80d497c] renamed test to test2
 1 files changed, 0 insertions(+), 0 deletions(-)
 rename {test => test2}/test.txt (100%)
gitbug/single$ git checkout master
Switched to branch 'master'
gitbug/single$ echo "change on master" >> test/test.txt
gitbug/single$ git commit -am "made a change on master"
[master 51d3a75] made a change on master
 1 files changed, 1 insertions(+), 0 deletions(-)
gitbug/single$ git checkout branch1
Switched to branch 'branch1'
gitbug/single$ echo "change on branch1" >> test2/test.txt
gitbug/single$ git merge master
Auto-merging test2/test.txt
Merge made by recursive.
 test2/test.txt |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
gitbug/single$ cat test2/test.txt
hi
change on master
gitbug/single$

I expected the merge to fail as it usually does when there is a
conflict with uncommitted changes.  Instead, it silently deleted the
changes in test.txt.

One of our developers just lost a few hours of work to this bug.  Please fix!

Sincerely,
Paul Grayson
--
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


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]