"Your local changes ... would be overwritten" bug
From: Hannu Koivisto <hidden>
Date: 2016-06-15 22:51:58
Greetings,
I have a problem where "git checkout origin/another-branch" in master
should remove a set of files but instead I get:
error: Your local changes to the following files would be overwritten by checkout:
file1
file2
...
Please, commit your changes or stash them before you can switch branches.
Aborting
(where the files listed are those that should be removed)
The problem occurs only if the checkout is not run in the top level
directory of the repository and the files in question have execute
bit set. Before checkout, git status says
# On branch master
nothing to commit (working directory clean)
The following script can be used to reproduce the problem:
-------------------------------------------
mkdir temp
cd temp
git init
echo foo > testfile
git add testfile
git commit -m "test1"
echo foo > testfile2
chmod +x testfile2
git add testfile2
git commit -m "test2"
mkdir foo
cd foo
git co master~1
--------------------------------------------
The problem disappears if one removes either the "chmod +x
testfile2" line or the "cd foo" line.
I'm running Cygwin git 1.7.5.1 in Windows XP.
--
Hannu