1

I'm running VSCode on WSL1, and my git repo is not being recognised by VSCode.

I've checked:

  • Git --version: 2.32.0 2.17.1
  • VSCode version: 1.58.1
  • Git SCM extension disabled and then re-enabled
  • git path and scan repositories set in the settings

None of these seem to make a different, but closing and reopening VSCode works maybe 1 in 10 times, or less.

How do I get git recognised without reloading?

AncientSwordRage
  • 7,086
  • 19
  • 90
  • 173

2 Answers2

2

It looked like my git repo has corrupted git objects, which I had to clean up before VSCode would recognise it. I used the commands here (assuming you were on master) to do so, which are currently:

rm -fr .git
git init
git remote add origin [your-git-remote-url]
git fetch
git reset --mixed origin/master
git branch --set-upstream-to=origin/master master

Note that since August 13th 2021, the [git-remote-url] should look like git@github.com:user/repo.git. To set that up refer to Connecting to GitHub with SSH

AncientSwordRage
  • 7,086
  • 19
  • 90
  • 173
1

Try first and upgrade Git (Both on Windows and in your Linux WSL1 VM, with ppa upgrade - the ppa upgrade will take you at least to 2.31 or 2.32.)

Consider using the Visual Studio Code Remote - WSL extension to access your Git repository more reliably.

AncientSwordRage
  • 7,086
  • 19
  • 90
  • 173
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Ahh sorry for not specifically saying so, but I am using VSCode remote. I'll look into upgrading git. Your linked PPA answer mentions upgrading to fit 2.11, however I'm on 2.17 as per my question... Do I need an even higher version? – AncientSwordRage Jul 27 '21 at 07:26
  • 1
    @Pureferret The ppa upgrade will take you at least to 2.31 or 2.32. It mentioned 2.11 because that was the latest at the time of writing that 2016 answer. – VonC Jul 27 '21 at 07:31
  • I've upgraded, and restartedVSCode and it seemed to make no change, but then eventually it seemed to load up. I'll keep an eye on how this behaves and accept if it seems more consistent than before – AncientSwordRage Jul 31 '21 at 08:43