Why do certain file types that should be ignored, continue to say I need to do something about them?

Yesterday I started a new Git repo, then copied source files from a TFVC repo into the Git repo. (I believe I got rid of all the TFVC related files.) I’m using Visual Studio 2019. After I created the local repo and pushed to remote, I realized that I’d forgotten to include the .gitignore file, so I went onto GitHub, found the relevant .gitignore for Visual Studio, and put it into the root of the repo. I thought that would be the end of it.

But I’m wrong. Every time I open the project with VS 2019, I’m presented with some files which Git sees ask having been modified, but not staged. For example, this is what I’m seeing now:

I’ve previously performed a git restore <file> on files like the .suo file, but it still comes back. Files like .suo, .dll and .cache are all in the .gitignore file, so why aren’t they being ignored? Is the order in which I added the .gitignore file important? How do I fix this so that it will stop bothering me?

The files in your screenshot are marked as modified, so they have already been committed to the repository. Files that are part of the repository are never ignored, you have to delete them from the index first.

You could use git rm --cached on those files to delete them from the index but not the working tree. You might want to also clean them from the history (or start over, given that the repository is still very new).

1 Like

Thank you very much, @airtower-luna, for your explanation. It makes sense. I now understand it.

Like you said the repo is still new enough. I think the quickest way for me to get this resolves is to delete it from my machine, the clone the repo again.

Thanks again!

1 Like