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

Bug? Git checkout fails with a wrong error message

From
YGYves Goergen <nospam.list@unclassified.de>
Date
Jan 12, 2012, 18:44 UTC
Message-ID
<loom.20120112T193624-86@post.gmane.org>
Hi,

I am using Git alone for my local software project in Visual Studio 2010. I've been on the master branch most of the time. Recently I created a new branch to do a larger refactoring of one of the dialogue windows. I did the following modifications:

* Rename Form1 to Form1a (including all depending files)
* Add new Form1

I checked this change into the branch, say form-refactoring. Interestingly, Git didn't notice that I renamed the file Form1.cs into Form1a.cs and created a brand new, totally different Form1.cs, but instead it noticed a new Form1a.cs file and found a whole lot of differences between the previous and new Form1.cs files. This will of course lead to totally garbaged diffs, but I don't care in this case as long as all files are handled correctly in the end.

Then I switched back to master to do some other small changes. Nothing conflicting. Until now, everything worked fine.

Today, I wanted to switch back to my branch form-refactoring to continue that work. But all I get is the following message:

----- git.exe checkout form-refactoring

Aborting error: The following untracked working tree files would be overwritten by checkout: Form1.Designer.cs Please move or remove them before you can switch branches. -----

What is that supposed to be? The mentioned file is not untracked. Neither in the master branch, nor in the form-refactoring branch. It is part of both branches, but one is not a descendent of the other (because it was recreated on the form-refactoring branch, if that matters). What would happen if I delete it, is it gone for good then? I don't trust Git to bring back the correct file if I delete something now. I did not play with any file at all outside of my mentioned Git operations, so why should I play around with any file to continue using Git operations now? Git broke it, Git's supposed to handle it now!

Here's some other input:

There are no uncommitted changes in my working directory. 'git status' doesn't list anything.

The file in question is not untracked. Right now on the master branch, it has a green checkmark in Explorer (provided by TortoiseGit) and it has a history as well. There are more Form....Designer.cs files that don't cause any trouble.

'git clean -f -d', 'git reset --hard HEAD', 'git stash' do nothing and don't help resolving the issue.

Right now, I cannot continue with my work because I cannot switch branches. Is there an easy solution to this? Is my Git repository broken, all by standard operations?

Next: Holger Hellmuth
Message 1 of 27 in “Bug? Git checkout fails with a wrong error message”
  1. Yves GoergenJan 12, 2012
  2. Holger HellmuthJan 13, 2012
  3. Yves GoergenJan 13, 2012
  4. Holger HellmuthJan 13, 2012
  5. Yves GoergenJan 15, 2012
  6. Holger HellmuthJan 16, 2012
  7. Yves GoergenJan 16, 2012
  8. Jeff KingJan 16, 2012
  9. Yves GoergenJan 16, 2012
  10. Jeff KingJan 16, 2012
  11. Yves GoergenJan 17, 2012
  12. Thomas RastJan 16, 2012
  13. Erik Faye-LundJan 16, 2012
  14. Yves GoergenJan 16, 2012
  15. Bug! Git merge also fails with a wrong error messageYves Goergen, Jan 13, 2012
  16. Jeff KingJan 13, 2012
  17. Yves GoergenJan 13, 2012
  18. Jeff KingJan 13, 2012
  19. Yves GoergenJan 13, 2012
  20. Carlos Martín NietoJan 13, 2012
  21. Yves GoergenJan 13, 2012
  22. Jakub NarebskiJan 13, 2012
  23. Yves GoergenJan 15, 2012
  24. Jakub NarebskiJan 15, 2012
  25. Thomas RastJan 17, 2012
  26. Yves GoergenJan 17, 2012
  27. Thomas RastJan 19, 2012

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.