21

So I've been using Visual Studio Code (VS Code) for a while and working on my project with Git and had no problem. I was able to clone the git repository to a work space then I would see the "master" at the bottom left corner showing that I cloned a master branch and am working on the master branch. Then Normally I can click on it and select "Create new branch" and create my own branch such as "off_master".

I don't know why, but since little over a week ago, when I clone a git repository, it downloads the files, but I don't see the the word "master" at the bottom left of VS Code. And when I click on "Create new branch" and give a name, I get a general git error:

Git: Failed to execute git

and I see these in the git log:

> git rev-parse --show-toplevel
> git checkout -q -b off_Master
> git rev-parse --show-toplevel

I have no idea why it's starting to do this. So I've uninstalled VS Code, deleted this directory which seem to have all the VS Code settings:

C:\Users\<myId>\AppData\Roaming\Code\

I've then reinstalled VS Code with latest and same thing happens.

When I issue git status from the directory which contains .git directory, I get an output like this:

On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean

So it looks like I am using the master branch, but VS Code is not showing. And somehow I cannot create a new branch from VS Code.

I also tried a command like git config --list and it does have correct user.name, user.email, and remote.origin.url and these which look OK:

remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

I am not very familiar with git, thus I use VS Code to drive the git, so it's very critical that I get this back to working state...

Any idea why this might be happening?

Only thing that makes me bit suspicious is that I was doing some stuff with Angular JS and upgraded NodeJS to do some stuff, but I wouldn't think these will have any impact to VS Code and git.

One other thing is that even if I removed that "Code" directory, when I reinstalled VS Code, it seemed to have all the extensions that I had installed previously, so it seems not everything was cleaned up.. How can I clean up everything so that it will look as if I am installing VS Code brand new? Perhaps doing this and reinstalling might help?

KHP
  • 379
  • 1
  • 2
  • 10

5 Answers5

50

Very late reply, but I recently had this issue and found a solution for it. Basically run git fetch --all in CMD inside the project directory and they should show up.

Mohammed Faour
  • 618
  • 5
  • 12
15

enter image description here

Steps to reproduce :

  1. Access the "Source Control" tab on the left side of VSCode
  2. Click on the "three small dots" next to the refresh button
  3. Go to "Pull, Push"
  4. Click on the "Fetch" option

Enjoy

If you would like to know more about creating a new branch and switch between branches : Switch between branches in VSCode

Julien J
  • 2,826
  • 2
  • 25
  • 28
4

Check if this is linked to the Git Lens VSCode plugin.

There have been some recent issues including issue 468.

You can launch VSCode with options, like --disable-extensions to see if the issue persists and might come from one of the installed plugins.


SendETHToThisAddress reports in the comments:

I went to Extensions >GitLens >settings icon >disable GitLens.
Then ran the command git fetch --all.
Finally the new branches appeared!

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I wiped out everything about VS Code (i.e. the Code directory which contains the settings and the .vscode directory which contains extensions. I think that's all I found to delete after I uninstall. Then I reinstalled and I'm still seeing the same unfortunately... – KHP Aug 15 '18 at 14:06
  • @KHP Can you try launching VSCode from a CMD where you have set the `%PATH%` to a simplified one? (as in https://stackoverflow.com/a/51759126/6309) – VonC Aug 15 '18 at 20:03
  • Tried with base Windows path + Git path, then went into the VS Code install directory and ran the code.exe and cloned to a new workspace which worked OK as usual, but still no "master" shown at bottom left screen and clicking refresh on Source Control gives "Failed to execute git" error. All the git commands I run manually seems to work fine. It's just that VS Code seems to have problem and not processing git data properly for whatever reasons since a week or so ago. – KHP Aug 15 '18 at 21:22
  • I went to Extensions >GitLens >settings icon >disable GitLens. Then ran the command `git fetch --all`. Finally the new branches appeared! – SendETHToThisAddress Mar 15 '21 at 19:33
  • @SendETHToThisAddress Thank you for this feedback. I have included your comment in the answer for more visibility. – VonC Mar 15 '21 at 19:43
  • In my case just running git fetch --all without disabling any plugins helped. – Mikhail Jan 27 '22 at 10:15
  • @Mikhail Sounds good then. It was not a plugin issue/interference in your case. – VonC Jan 27 '22 at 11:06
1

git fetch --all

I think your issue will solve by firing command git fetch --all

Do fire command a git fetch to retrieve the new branches.

ShraOne Devade
  • 199
  • 1
  • 5
0

Issue was unselect Status Bar from View -> Appearance -> Status Bar

You can fix it from below attached screenshots:

screenshot before Status Bar unselect

screenshot after Status Bar Select

Alam
  • 303
  • 1
  • 3
  • 14