microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.64k stars 29.04k forks source link

Git branch inconsistencies #165350

Closed BrianPittVP closed 1 year ago

BrianPittVP commented 1 year ago

Type: Bug

The lower status bar displays the current Git branch, however, this is often inaccurate. If I use the status bar to select a branch, everything works fine. But if I use the Terminal to check out a git branch, the status bar does not update.

VS Code version: Code 1.72.2 (d045a5eda657f4d7b676dedbfa7aab8207f8a075, 2022-10-12T22:15:18.074Z) OS version: Windows_NT x64 10.0.22000 Modes: Sandboxed: No Remote OS version: Linux x64 4.4.0-1128-aws

System Info |Item|Value| |---|---| |CPUs|11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz (16 x 2304)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|undefined| |Memory (System)|31.73GB (16.88GB free)| |Process Argv|--crash-reporter-id a306a1bd-3e7b-4917-a64e-69b7ab976500| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|SSH: local| |OS|Linux x64 4.4.0-1128-aws| |CPUs|Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz (2 x 2500)| |Memory (System)|7.59GB (5.99GB free)| |VM|0%|
Extensions (12) Extension|Author (truncated)|Version ---|---|--- Bookmarks|ale|13.3.1 compare-helper|kee|1.1.0 remote-ssh|ms-|0.90.1 remote-ssh-edit|ms-|0.84.0 vscode-intelephense-client|bme|1.8.2 githistory|don|0.6.19 xml|Dot|2.5.1 php-docblocker|nei|2.7.0 vscode-php-getters-setters|php|1.2.3 vscode-xml|red|0.22.0 php-debug|xde|1.29.0 php-pack|xde|1.0.3
vscodenpa commented 1 year ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.73.0. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

BlaM commented 1 year ago

I just updated to Version 1.73.0 and since that update I can see the same problem. The footer keeps telling me that I'm on the "master" branch and also the "Source Control" tab tells me that I can commit to the "master" branch - I'm on a different branch, though (and when I commit my commit goes to the branch that I'm actually at).

Running git status on the terminal also confirms that I'm working in another branch.

Y:\pagecode-dd> git status
On branch feature/SCP-1299

I can change to another branch via that click in the status bar, too - but it sticks with telling me that I'm on "master".

[Update] Probably not relevant, but still mentioning: I'm also using the remote-ssh and remote-ssh-edit extensions. BUT: It does not matter if I open the folder through SSH or locally.

jNullj commented 1 year ago

I tried to replicate this issue on linux and failed, once i switch branch gui updates to new branch

jNullj commented 1 year ago

There seems to be a few constrains to refreshing the branch

  1. is the window in focus when you wait for the branch to update?
  2. how big is your repository?
  3. is "autorefresh" enabled in settings?
BlaM commented 1 year ago

For me the answers are "yes", "small to medium" and "yes".

I just noticed that the problem is probably related to the use of git worktrees. VSCode shows the correct branch if I work in the "original" repository, but not in worktree folders.

[Update] I think I can confirm that worktree directories always show the branch that is actually checked out in the "source" directory (the one, where the full repository lives)

BlaM commented 1 year ago

Steps to reproduce: (via Windows cmd - not sure if we see the same problem in other OS)

mkdir test
cd test
git init
echo test >test
git add test
git commit -m "test-commit in master branch"
git worktree add ../bla -b bla

This will create a new repository in a directory called "test", then adds a dummy commit into the master branch and finally creates a worktree directory in the directory "bla" alongside "test" where it checks out a new branch "bla". When opening the folder "bla" in VS Code you will see "master" as the checked out branch (which is actually checked out in "test").

(So this may be unrelated to the initial issue description? Probably I'm with this -> #165425)

lszomoru commented 1 year ago

Duplicate of https://github.com/microsoft/vscode/issues/164363

BrianPittVP commented 1 year ago

I do not use Worktrees (that I'm aware of), and I'm still seeing this problem in version 1.73.0. This was marked closed, I just want to make sure it's definitely related to #164363, or re-open this if it's a separate issue.

lszomoru commented 1 year ago

@BrianPittVP, could you please download the latest Insiders release and see if you are still able to reproduce? Thanks!

BrianPittVP commented 1 year ago

Love to....where do I find the "insiders" release?

lszomoru commented 1 year ago

@BrianPittVP, you can download it from https://code.visualstudio.com/insiders/