0

In my Visual Studio project, I have a file that was "deleted" - it's actually still there at that same location. If I try to undo the changes, nothing happens. If I run a git status it detects no changes. I don't want to see this "ghost" file in my pending changes, any ideas on what to try to get rid of it?

Git Bash vs. Pending Changes

LeGEC
  • 46,477
  • 5
  • 57
  • 104
test
  • 2,589
  • 2
  • 24
  • 52
  • 3
    Why has this got a c# tag though?? – Yossi Sternlicht Jun 14 '22 at 21:45
  • Has your change ever been committed, pushed, and merged to master? It's saying that you've deleted the class, and that's the change that you have there. – Josh Heaps Jun 14 '22 at 22:41
  • @JoshHeaps yes it has. for this change that it shows in Team Explorer, I can't stage it or commit it. it just does nothing and keeps the change there. – test Jun 14 '22 at 23:24
  • 3
    What version of VS is it? Can you try staging the file and see if it goes away? This may be a [duplicate of this](https://stackoverflow.com/a/40140732/184546). – TTT Jun 15 '22 at 04:35
  • @TTT unfortunately I have tried to stage the file but nothing happens. if i try to commit with actual changed files it still remains. this is VS 2017 Enterprise 15.9.48 – test Jun 16 '22 at 22:42
  • Oh- sorry. I just noticed in your previous comment you said you tried staging it already. What if you actually delete it, and then try to undo the delete from VS? Or maybe edit that file. I don't know what VS is doing behind the scenes, but it's obviously confused. Perhaps touching that file in some way can slap VS back into reality. – TTT Jun 17 '22 at 13:57
  • If the ideas in my previous comment don't work... here's another (unlikely) idea: Does that file on your local drive have the identical casing as "QueryString.cs"? (Capital 'Q' and 'S' only?) I've seen weird things like this happen when two files exist in the repo but differ by casing only. I don't think this is the problem since normally when that happens `git status` would also report the file as deleted, but maybe VS is using a different version of Git and/or has its own config settings vs your command line. – TTT Jun 17 '22 at 14:13
  • 1
    @TTT I have tried deleting the file, committing the delete, then adding it back in. Still glitched. I do believe the issue did come from renaming it a while ago from Querystring.cs to QueryString.cs however, any attempts to rename it back are not working – test Jun 20 '22 at 18:07
  • Take a look at [this answer](https://stackoverflow.com/a/67095620/184546) to see if you have two different files in the repo with the same case. – TTT Jun 20 '22 at 19:08
  • @TTT I was able to resolve it, see answer. Thanks for sticking with me. – test Jun 20 '22 at 19:30
  • @TTT Welp, nevermind. It came back on the next commit. – test Jun 20 '22 at 19:42
  • @test did you confirm if you have 2 different copies stored in the repo using `ls-tree`? Or, does the one that is stored in the repo have different casing than the current file? – TTT Jun 21 '22 at 00:02
  • @TTT I'll be honest, I just gave up after trying a bunch of stuff. I ended up renaming the file to `QueryStringCollection.cs` and it has it has gone away and seems to remain gone from commit to commit. Not ideal I know. – test Jun 21 '22 at 14:32
  • @test well, I'm glad it's resolved! – TTT Jun 21 '22 at 15:48

0 Answers0