12

I am using Visual Studio Code 1.6.0 on a Macbook.

I'm finding that the VS Code's Git is listing tons of changes - even ones that are not in my working folder?

When I hover over these I get a tooltip:

This file is located outside the current workspace.

Please advise how I can remove all these from the Git panel.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Dr T
  • 504
  • 1
  • 7
  • 20

4 Answers4

9

Here is how you can avoid such issues in VSCode

  • Go back to folder using cd ..
  • Check if git has been initialzed using git status
  • If yes, remove git tracking with command rm -rf .git
  • Repeat this until you reach your root directory
  • and reload your vs code to track current directory
Suman Kharel
  • 920
  • 11
  • 13
8

You probably have a git repo initialized in a directory above you. Try looking for a .git folder in each folder above your workspace, maybe on the root of the drive. If you don't want it, you can just delete that folder.

Rob Lourens
  • 15,081
  • 5
  • 76
  • 91
  • Remember that it won't show up in Finder by default - look using the Terminal – Rob Lourens Nov 04 '16 at 16:45
  • Thanks for replies. At first glance that does not seem to be the case. However, I will look again. I know there are .git folders in other folders but they are siblings - and these are the ones that seem to be getting picked up by VSC. – Dr T Nov 04 '16 at 22:49
7

The setting for VS Code is "git.autoRepositoryDetection":

Possible values:

true : default. scans subfolders and parent folders of open files

openEditors: scans parent folders of open files

false: detects only the open folder

subfolders: scans subfolders for .git (but not parent folders)

I have it on false to work on the current directory.

"git.autoRepositoryDetection": false

dimpen
  • 146
  • 2
  • 3
0

Similar to the other answers with .git files in the wrong directory, I ran into this same issue because I had a package.json and yarn.lock in the wrong directory (I had accidentally run "yarn add [package]" in the parent folder), and VSCode thought that every single file in my repo was untracked (1k+ unstaged changes).

I got rid of them and that made VS Code happy.