Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Visual Studio Code for Windows, the Git branch doesn't show and can't create a branch

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?

like image 558
KHP Avatar asked Aug 15 '18 00:08

KHP


2 Answers

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.

like image 80
Mohammed Faour Avatar answered Oct 10 '22 20:10

Mohammed Faour


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!

like image 4
VonC Avatar answered Oct 10 '22 20:10

VonC