VS Code Source Control is listing every file on my computer

Yves Boutellier
Dev Genius
Published in
5 min readOct 23, 2021

--

Two possible causes

If this message appeared in your VS Code as well, I got your back. I received this warning, when I started to program my first app in flutter. I decided to use VS Code since nearly every tutorial shown on youtube is done in VS Code. Overwhelmed by the many new terminology when programming in dart and flutter I thought I want to be able to stick to the most seen IDE because a large user-base means many tutorials which helps to minimize frustration.

But unexperienced with VS Code I did not know how I should interpret such a warning and I could not imagine where things might have gone wrong. I ignored this problem until I needed to use branches because I wanted to develop new features which could break the rest of the code.

Photo by Daria Kraplak on Unsplash

First Cause — EOL Issue

I first googled this just this warning message. Like probably you did. I found a StackOverflow question that asked exactly this. https://stackoverflow.com/questions/60160453/vs-code-the-git-repository-has-too-many-active-changes-only-a-subset-of-git-f

Maybe you visited this question on SO before you saw this article. I read the answers to the question and it left me more confused than before.

The most popular answer was about End-of-Line issue (EOL). You can check if it is an EOL-Issue by running ls-files --eol . If so, do the following steps:

  1. type git config — global core.autocrlf false
  2. re-clone your repository
  3. check if the issue persists on VSCode

This is a problem for cross-platform files, as seen in flutter. Basically, Unix and Mac OSX (pre-OSX uses CR) clients use LF line endings while Windows clients use CRLF line endings. In some cases these endings are changed (conversion) which leads results in Git seeing changed files (but really there are no changes). This post does not look it in more detail (I solved my problem with the second cause), if you are interested, I list some discussions and resources to that at the bottom of the article. [1][2][3]

Second Cause: VS Code Source Control is listing every file on my computer

I decided to search for other causes since I was not enough convinced to use this suggested three steps. I went to VS code again and on the left-hand panel I looked at source control. I had a glimpse at the changed files. It made really no sense to me. I detected Python files and anaconda files, even some files from secondary school. This was odd. However, I had realised that with this information I could try another attempt googling my problem. I searched “VS Code Source Control is listing every file on my computer”. And I found an article that helped me through this. And I want to make this information easily actionable for you!

  • Go in your terminal to the project folder with which you are experiencing problems.
  • write git rev-parse --show-toplevel

This command searches for a the .git folder that is higher up in the directory tree of your files and it will return the location of the first encountered git repository. This means you either will receive a fatal not found or a path. If you receive a path, you are a happy person, because the rest of this tutorial will help you to solve the problem you had in the first place.

  • fatal: not a git repository (or any of the parent directories): .git (THIS MEANS THIS TUTORIAL WILL NOT HELP YOU ANY FURTHER)
  • /Users/[username]/../[arbitrary] (or any other path that appears)

This path /Users/[username]/../[arbitrary] is the location to a folder (let’s call it A for simplicity) which has a .git folder. In this folder A there are presumably other folders as well and these folders have subfolders and these have subfolders too and so on. Your project that you are working on and for which you received this stupid warning is in one of these subfolders. VS Code searches for any .git folder in the project folder or higher up and lists all files that are part of one of these subfolders of A.

Now to solve this problem we need:

  1. to go to this address we received before /Users/[username]/../[arbitrary] by using cd .. until we arrive there
  2. then we should check what commits were done to this repository by typing git log --stat and if it is connected to any remote repo by using git remote -v
  3. if it’s safe to delete type in yes | rm -r .git
  4. then we go to our project folder cd [somepath]/../..
  5. write git rev-parse --show-toplevel this time we want to receive fatal: not a git repository (or any of the parent directories): .git
  6. if so, we want to create a .git folder by using the command git init
  7. stage all files git add -A
  8. commit files git commit -m "finally can commit"

And you are done. Congratulation!!

Photo by Sharon McCutcheon on Unsplash

Why did I have this problem?

Honestly, I think the cause of my problem was my inexperience at the beginning of my programming journey. I assume that I accidentally wrote git init in a folder and did not know how to delete it and did not know how to search for it after creation and I let it there. Retroperspectively I should have made more effort to clear this accident. Two years later this .git folder disturbed my workflow because I used VS code and I finally realized that I had this unnecessary and potential harmful organisation. Happily, I solved it for me and I hope you could solve your error too.

Useful Resources

Git Basics for ML Project

Git Branches for ML Project

Inspiration for this article

[1] https://rehansaeed.com/gitattributes-best-practices/

[2] https://stackoverflow.com/questions/3206843/how-line-ending-conversions-work-with-git-core-autocrlf-between-different-operat/14039909#14039909

[3] https://stackoverflow.com/questions/5787937/git-status-shows-files-as-changed-even-though-contents-are-the-same/35204436#35204436

--

--