I had already tracked files that I wanted to add to the .gitignore
file (e.g. App.config), so I followed the advice of this post (and others like it), and did the following:
- ran
git rm --cached *.config
- added
*.config
to my.gitignore
file - git added and commited the ignore file and the "deleted" files
After doing the App.config
file, I double checked, and the file was there, with the little symbol for "ignored" next to it in Visual Studio. Everything seemed peachy, so I did this for several files every few commits as I came across other things I thought should be added to the .gitignore
, including *.csproj
(which I now regret very much).
It was all fine until today when I had to switch to the master branch for a moment, and the project (my dev branch) had to be reloaded. The load failed and when I tried to re-load, it said :
The project file <missing file.csproj> has been moved, renamed, or
is not on your computer.
Lo and behold, all the files I had untracked are now gone when I search in file explorer.
I've been going back through commits, and the "missing file" error goes away before that file was "removed from the cache" (aka deleted, even though it wasn't deleted after I committed it, since I've been working in it without issue until now). I'm stumped as to why git deleted these files.
If anyone has advice on a solution, I'm all ears; the current plan is to copy the code I've changed on this branch and restart on a new branch from master, but I'd rather not have to redo everything I've been working on the past couple weeks. Regardless, my main question is why this happened in the first place so I can avoid doing it again.