Source Control in VSCode is not refreshed automatically
Asked Answered
C

12

30

I have updated Mac OS from Sierra to Monterey recently. Since then I have been facing some issues. One of them is in VSCode, when I do changes to the files the changes are not reflected in Source Control or Explorer until the refresh button is clicked manually in Source Control Tab. Can anyone help me out to solve this issue?

I have git 2.16 installed in my machine.
I have updated the version of VSCode and git.autorefresh is set to true.

Update 1:
I have reinstalled git. Now I have git 2.35.1. But still, the Source Control tab is not auto refreshed.

Cephalonia answered 19/2, 2022 at 1:48 Comment(1)
This is a bug in vscode. The related issues are these: 64775 (closed), 42821 (closed) and 5970 (open as of May 2022).Binge
C
3

I had my project in /System/Volumes/Data/<my-folder-name>. After moving to /Users/<user-id>/, it started working. I even created a simple project in both the folders and tested them. Project in the former path faces the issue whereas the latter one doesn't face any issue. So I moved my work to the Users folder but I don't know the root cause.

Cephalonia answered 23/2, 2022 at 8:7 Comment(3)
I faced the same issue, in my case I had special characters in folder's name, after changed it, it worked just fine after a vs code restart.Crabwise
I have the same problem. My folders structure is: //wsl.localhost/Ubuntu-20.04/home/username/project - Could it be that the dot is causing the problem here? But I can't change the name of my wls folder...Introspect
klediooo same issue hereAbnaki
D
18

As Visual Studio Code "Version Control" page mentions:

Note: VS Code will leverage your machine's Git installation, so you need to install Git first before you get these features. Make sure you install at least version 2.0.0.

So first of all make sure you have installed git on your machine(GIT FOR macOS).

Then

  • Open the command palette in vscode(In mac,Press ‘’Cmd + Shift + P’’):
  • Type "open settings"
  • choose "Open Settings (JSON)

In the setting.json file, add the following flag for auto-refreshing: "git.autorefresh": true,

Then save the changes. your problem should be solved.

In addition, There are more git config that you can use them(just type git in setting.json file for more options)

Dd answered 22/2, 2022 at 7:16 Comment(7)
Thank you for the solution. I have git installed already versioned 2.16 and even git.autorefresh is set to true. But still I face this issue.Cephalonia
Thanks! Adding "git.autorefresh": true, worked for me :)Ammadas
Worked for me, Ubuntu 22.10 arm64 VScode 1.76.0. Make sure to reload your VScode after you add the setting in the json otherwise you will be scratching your head thinking what the heck that did.Siffre
This worked... but gotta be the dumbest thing that VScode doesn't do this automagicallyLifeordeath
This does NOT work for me. I am running debian 11.4.Induline
related: Why don't other programs see the changes I made to a file in VS Code until I save those changes?Worrell
dont had "open settings" in the command pallette but similar entries. Instead I went File -> Preferences -> Settings and switched to JSON (top right icon in the dialog). Only hat git.autofetch set to true, adding autorefresh solved it fully.Tameka
B
12

Even though my setting in 'Open Default Settings (JSON)' had "git.autorefresh": true, I also had to add this to 'Open User Settings (JSON)' and now it works.

Brentwood answered 11/12, 2022 at 23:25 Comment(1)
This solved my issue, thanks - started happening out of nowhere despite autoRefresh always working beforeApocalyptic
C
3

I had my project in /System/Volumes/Data/<my-folder-name>. After moving to /Users/<user-id>/, it started working. I even created a simple project in both the folders and tested them. Project in the former path faces the issue whereas the latter one doesn't face any issue. So I moved my work to the Users folder but I don't know the root cause.

Cephalonia answered 23/2, 2022 at 8:7 Comment(3)
I faced the same issue, in my case I had special characters in folder's name, after changed it, it worked just fine after a vs code restart.Crabwise
I have the same problem. My folders structure is: //wsl.localhost/Ubuntu-20.04/home/username/project - Could it be that the dot is causing the problem here? But I can't change the name of my wls folder...Introspect
klediooo same issue hereAbnaki
T
3

In my case I have added this parameter in VS settings.

 "git.autofetch": true,
Tapeworm answered 20/6 at 13:36 Comment(0)
A
1

This problem seems to happen in different versions for different reasons. As of April 2023, I solved it by cmd + p -> "git: open repository" -> select your main git repository. Probably because I opened a subfolder only instead of the main one with git.

Acidophil answered 20/4, 2023 at 13:57 Comment(0)
B
0

I had the same issue, when I staged/unstaged parts of a file, it would not update before I switched to another window and back again. I'm on Ubuntu 22.04 LTS with Git 2.34.1 and vscode 1.74.3. I set this config in vscode:

"git.closeDiffOnOperation": true

Edit: Unfortunately this only works on my desktop and not my laptop, even though they both run the same ubuntu, git and vscode.

Burnside answered 16/1, 2023 at 17:29 Comment(0)
C
0

I had the same issue. Other than that, I also had trouble with VSCode auto-import, it kept ignoring new files and I had to reload my IDE to fix it.

Both issues were caused by the fact I was on WSL2 (Windows 10), but I was working on a project without using the WSL VSCode extension. The solution was (drum roll) installing the extension. I used it to connect to my project and boom both issues went away.

Cracksman answered 21/6 at 15:8 Comment(0)
C
0

I solved moving my project_A from /mnt/c/Users/username/OneDrive/Desktop/project_A to ~/project_A

The error happens because settings.json related to WSL refers to /home/username

Chinua answered 27/6 at 14:11 Comment(0)
M
0

For me, restarting the vs code (as i had received an upgrade) worked for me.

Mata answered 8/8 at 9:32 Comment(0)
R
0

Same problem happened to me because VSCode was in read-only file system. As soon as I moved VSCode to read-write, the problem was solved.

Retract answered 13/8 at 11:30 Comment(0)
C
0

If you come to this issue like me since new version of vscode (mine 1.92.2)

typescript.tsserver.experimental.useVsCodeWatcher solve for me the issue

Check that you have "git.autofetch": true too

Cribbs answered 4/9 at 23:25 Comment(0)
G
0

I solved this by changing this in Fedora Linux (I imagine it would be the same in systems that have sysctl), the problem seems to be that VSC is not able to watch changes in a file because the workspace is too large. To do this you must increase the max_user_watches in /etc/sysctl.conf by adding the following:

fs.inotify.max_user_watches=524288

You can see the current value by running:

cat /proc/sys/fs/inotify/max_user_watches

Then to load the new value run sudo sysctl -p

Also if we don't want to modify the value we must go to the root of the problem, which is that the workspace is too big, to solve it we can tell VSC to skip certain directories. This can be added in the settings.json of your choice or via the settings UI in my case I have added these in User Settings (JSON):

"files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/*/**": true,
    "**/.hg/store/**": true,
    "**/vendor/*/**": true,
}

In my case, the first 4 patterns were already there, so by adding the vendor (the project is with Laravel) it already works for me.

Source: "Visual Studio Code is unable to watch for file changes in this large workspace" (error ENOSPC)

Gleeful answered 18/9 at 21:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.