14

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.

vbrin27
  • 723
  • 1
  • 6
  • 25
  • 3
    This is a bug in vscode. The related issues are these: [64775](https://github.com/microsoft/vscode/issues/64775) (closed), [42821](https://github.com/microsoft/vscode/issues/42821) (closed) and [5970](https://github.com/microsoft/vscode/issues/5970) (open as of May 2022). – Carlos Pinzón May 09 '22 at 16:56

5 Answers5

7

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)

MHM
  • 194
  • 1
  • 9
  • 4
    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. – vbrin27 Feb 23 '22 at 05:34
  • 2
    Thanks! Adding `"git.autorefresh": true,` worked for me :) – Snailedlt Jun 30 '22 at 11:10
  • 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. – HackerDaGreat57 Mar 05 '23 at 23:35
  • This worked... but gotta be the dumbest thing that VScode doesn't do this automagically – Matt Styles Apr 07 '23 at 12:01
  • This does NOT work for me. I am running debian 11.4. – sgon00 Jun 07 '23 at 17:20
  • related: [Why don't other programs see the changes I made to a file in VS Code until I save those changes?](/q/76984829/) – starball Aug 26 '23 at 22:37
4

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.

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.

vbrin27
  • 723
  • 1
  • 6
  • 25
  • 1
    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. – CevaComic May 20 '22 at 22:32
  • 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... – klediooo Nov 04 '22 at 15:28
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.

Mistborn
  • 1
  • 1
0

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.

Sheldon Oliveira
  • 915
  • 9
  • 15