43

It’s not about using .gitignore to ignore certain files, it’s about completely excluding that particular repository from file watcher of VS Code.

It complains that there’s more than 5000 files are opened and then just hanged my laptop. This repository has insane amount of files, and it’s located in my home folder as my configs are stored in git, in .gitignore I’ve added all files to ignore, and when I need to stash the files I’m using git add -f <file>.

As you can see on the picture, the repository "holms" is always opened, and it's causing me issues. This is parent repo, which is in my home folder. How can I ignore it completely? If I close that repo, it appears again after like 3 minutes of working in a editor

enter image description here

6
  • Tools -> Options -> Source Control -> Plug in selection -> Set to none. Commented Mar 16, 2018 at 18:15
  • github.com/Microsoft/vscode/issues/35480, when done, should help you
    – max630
    Commented Mar 16, 2018 at 19:01
  • @miqdadamirali vscode doesn't have such menu options. You probably talking about full visual studio
    – holms
    Commented Mar 23, 2018 at 12:22
  • 2
    @max630 it's not exactly that, in repo panel there's previous repo opened, i'm closing it every time, would be nice just to ignore it already
    – holms
    Commented Mar 23, 2018 at 12:23
  • @holms My mistake on that. For VS Code, try the following. File -> Preference -> Settings and in the custom User Settings (Right panel), add the following: "git.enabled": false,` Commented Mar 23, 2018 at 16:29

6 Answers 6

63

Had the same problem, try adding option:

"git.autoRepositoryDetection": false

and close repo from your parent (home) folder. It shouldn't appear again.

Update:

There's now an option to watch only repositories for opened files: "git.autoRepositoryDetection": "openEditors"

This way, if you open any file in a specific repository, vscode will only watch it.

1
  • 3
    The second setting saved me from ignoring the whole repo directory from the workspace; thanks for that! Now my submodules show up in the explorer without cluttering the Version Control sidebar!
    – Arcsector
    Commented Oct 21, 2020 at 5:39
50

Another solution is to use the Ignored Repositories in settings, for example to ignore the repository in home directory you can add:

"git.ignoredRepositories": [
    "/home/holms"
],

Or from the settings editor (my username is obi)

enter image description here

4
  • 3
    This solution was the only one that really worked for me. I have sub repos that just cluttered up the Source Control pane and this did the trick.
    – Liam
    Commented Feb 25, 2021 at 10:59
  • 3
    worked for me too, but only if I add the paths with double-backslashes (I'm on windows) e.g. someting like D:\\folder1\\folder2
    – raphael
    Commented Mar 19, 2021 at 20:44
  • 2
    This is working solution especially if you have a repositories within a repository. Commented Jan 24, 2022 at 23:15
  • 3
    This should be the accepted solution, because it is the only one that is explicit enough for every use case.
    – Akito
    Commented Nov 6, 2022 at 15:43
6

In VS Code 1.80, all you should need to do is close the repository. From the release notes:

In the past, users could close a repository either using the Git: Close Repository command or the Close Repository action in the Source Control view but there were certain actions (for example, opening a file from the closed repository) that would reopen the closed repository. This milestone we have made some improvements so the fact that a repository is closed is now persisted per workspace. Users can reopen closed repositories using the Git: Reopen Closed Repositories... command.

You can close a repository using the "Close Repository" item in the context menu of the repository in the SCM View, or the Git: Close Repository command in the command palette.

4

You could also select which repositories to hide manually:

enter image description here

3
  • 5
    Seems to reset every time I restart VSCode. Commented Feb 2, 2021 at 19:54
  • 3
    Yeah this does indeed reset when you reload the window
    – Liam
    Commented Feb 25, 2021 at 10:51
  • 1
    This answer by starball is more latest - which talks about how to persistently close a repository.
    – Gangula
    Commented Dec 5, 2023 at 10:29
3

Open `source control repositories view enter image description here And select the main repository you want. It won't be reset after restarting.

1
  • Only solution that worked for me, all the other flags had no effect when set in the project's vscode settings
    – Joan Rieu
    Commented May 13, 2023 at 18:12
0

Another option is to look inside .vscode/settings.json and adjust the settings there. In my case, I wanted to see the contents of the Library folder, so I set

    "Library/":false,

Previously it was set to true.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.