-
Notifications
You must be signed in to change notification settings - Fork 37k
Description
Description
When switching git branches in VS Code (either via the command line or VS Code's git UI), VS Code automatically restores the editor state (open files/tabs) from the last time that branch was checked out. This causes the currently open editor tabs to be replaced with previously viewed files from the target branch.
Desired Behavior
Users should be able to switch branches while preserving the currently open editor tabs, allowing them to continue viewing the same files in different branch contexts. There should be a setting that allows this functionality to be toggled, or a command that modifies the branch-switching behavior on an as-needed basis.
Current Behavior
- User has files A, B, C open while on branch
feature-branch - User switches to branch
main/default - VS Code closes files A, B, C and opens files X, Y, Z (which were open the last time
main/defaultwas checked out) - User wants to keep A, B, C open and just switch the branch context
Expected Behavior
When switching branches, the open editor tabs remain the same, and only the file contents update to reflect the branch being checked out.
Use Case
This is particularly useful when comparing changes between branches or when needing to view the same files across different branches without losing your editor state.
Workarounds Attempted
- Searched for and attempted to use relevant VS Code settings (e.g.,
window.restoreWindows,scm.preserveContextAcrossCheckouts) - none control this specific behavior - Branch-specific editor state restoration appears to be hardcoded behavior in VS Code
Environment
- OS: macOS
- VS Code: Latest