git/list[1] front-page[2] threads[3] people[4] search[5] about
 

"Your local changes ... would be overwritten" bug

From
HKHannu Koivisto <azure@iki.fi>
Date
Sep 5, 2011, 16:25 UTC
Message-ID
<8362l73qi6.fsf@kalahari.s2.org>
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
Next: Matthieu Moy
Message 1 of 6 in “"Your local changes ... would be overwritten" bug”
  1. Hannu KoivistoSep 5, 2011
  2. Matthieu MoySep 5, 2011
  3. Vijay LakshminarayananSep 5, 2011
  4. Andrew ArdillSep 5, 2011
  5. Clemens BuchacherSep 6, 2011
  6. Hannu KoivistoSep 6, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.