🫰 Snap Branch: automatic workspace switching for Git branches
A VS Code extension that automatically saves and restores workspace configurations per Git branch. As AI allows developers to context switch faster, reducing cognitively load of switching contexts helps developers to work faster.
Features
- 🔄 Automatic Branch Detection: Monitors Git branch changes and automatically switches configurations
- 💾 Workspace Configuration Storage: Saves open files, editor layout, and workspace settings per branch
- 🎛️ Configurable Behavior: Control what gets saved/restored (files, settings, layout)
- 📊 Status Bar Integration: Shows current branch and configuration status
- 🚀 Manual Management: Commands to manually save, restore, and manage configurations
How It Works
Automatic Mode: When you switch Git branches, the extension automatically:
- Saves your current workspace configuration to the previous branch
- Restores the workspace configuration for the new branch (if one exists)
Manual Mode: Use commands to manually save and restore configurations:
Snap Branch: Save Current Workspace Configuration
Snap Branch: Restore Workspace Configuration for Current Branch
What Gets Saved
For each branch, the extension can save:
- Open Files: List of currently open files in the editor (always included when enabled)
- Editor Layout: Active editor and visible editors (always included when enabled)
- Workspace Settings: Key settings like font size, theme, rulers, exclusions, etc. (opt-in only)
Non-Intrusive by Default
Important: By default, Snap Branch operates completely in the background without modifying any workspace files. It only manages:
- Which files are open in your editor
- Your editor layout (split views, active editor)
Workspace settings are NOT modified unless you explicitly enable snapBranch.includeWorkspaceSettings
. This means:
- ✅ No
.vscode/settings.json
modifications by default
- ✅ No workspace configuration files are touched
- ✅ Completely transparent operation
- ✅ Safe to use in any project without side effects
If you want the extension to also save and restore workspace settings (like theme, font size, etc.), you can enable snapBranch.includeWorkspaceSettings
in your VS Code settings.
Configuration
Open VS Code settings and search for "Snap Branch":
Setting |
Default |
Description |
snapBranch.autoSave |
true |
Automatically save workspace configuration when switching branches |
snapBranch.autoRestore |
true |
Automatically restore workspace configuration when switching branches |
snapBranch.includeOpenFiles |
true |
Include open files in workspace configuration |
snapBranch.includeEditorLayout |
true |
Include editor layout in workspace configuration |
snapBranch.showStatusBar |
true |
Show branch configuration status in status bar |
snapBranch.includeWorkspaceSettings |
false |
Include workspace settings in configuration (will modify .vscode/settings.json when enabled) |
Commands
Access these commands via Command Palette (Ctrl+Shift+P
/ Cmd+Shift+P
):
- Snap Branch: Save Current Workspace Configuration - Manually save current workspace state
- Snap Branch: Restore Workspace Configuration for Current Branch - Manually restore configuration
- Snap Branch: Show All Branch Configurations - View and manage all saved configurations
- Snap Branch: Delete Configuration for Current Branch - Remove configuration for current branch
- Snap Branch: Toggle Auto Branch Configuration - Enable/disable automatic switching
Status Bar
The status bar shows:
- Current Git branch name
- Configuration indicator:
●
(saved) or ○
(not saved)
- Auto-switching status
Click the status bar item to open the configuration management interface.
Usage Examples
Feature Development Workflow
Main Branch: Keep a clean workspace with only essential files
git checkout main
# Extension automatically restores main branch configuration
Feature Branch: Work with specific files and settings for the feature
git checkout -b feature/new-auth
# Configure workspace as needed (open relevant files, adjust settings)
# Extension automatically saves configuration when you switch away
Bug Fix: Quick context switch with appropriate debugging setup
git checkout hotfix/bug-123
# Extension restores previous bug fix workspace or creates new one
Settings Per Branch
Different branches might need different configurations:
- Frontend branches: Light theme, smaller font, CSS files open
- Backend branches: Dark theme, larger font, API documentation open
- Documentation branches: Markdown preview, spell check enabled
Installation
From Source
- Clone or download this repository
- Install dependencies:
npm install
- Compile TypeScript:
npm run compile
- Press
F5
in VS Code to launch extension development host
- Or package with
vsce package
and install the .vsix
file
Requirements
- VS Code 1.74.0 or higher
- Git repository in workspace
- Git extension enabled (built-in)
Contributing
Contributions welcome! Please submit a pull requests.
License
MIT License - see LICENSE file for details.
Changelog
1.0.2
1.0.1
- BREAKING CHANGE: Made extension non-intrusive by default
- NEW: Added
snapBranch.includeWorkspaceSettings
setting (default: false)
- IMPROVED: Extension no longer modifies
.vscode/settings.json
by default
- IMPROVED: Completely transparent operation - only manages open files and editor layout
- IMPROVED: Safer for use in any project without side effects
1.0.0
- Initial release
- Automatic branch detection and configuration switching
- Manual configuration management commands
- Status bar integration
- Configurable behavior settings