VS Code Git and Source Control Keyboard Shortcuts
Manage Git operations directly from VS Code using keyboard shortcuts for staging, committing, diffing, and branch management without the terminal.
Detailed Explanation
VS Code Git Shortcuts
VS Code has built-in Git integration that lets you perform most source control operations without opening a terminal. These shortcuts streamline the Git workflow.
Opening Source Control
- Open Source Control (
⌃+Shift+G/Ctrl+Shift+G) — jump directly to the Source Control panel showing changed files - Toggle Sidebar (
⌘+B/Ctrl+B) — show or hide the sidebar where Source Control lives
Inline Diff
VS Code shows inline diff gutters in the editor. Click the gutter to see changes inline:
- Go to Next Change (
⌥+F5/Alt+F5) — jump to the next modified section in the file - Go to Previous Change (
⌥+Shift+F5/Alt+Shift+F5) — jump to the previous change
Stage and Commit
While there is no default single-key shortcut for staging, the Source Control panel supports keyboard-driven workflow:
- Open Source Control (
⌃+Shift+G) - Navigate to files with arrow keys
- Press
Enterto open the diff - Use the Command Palette for Git: Stage Changes, Git: Commit, etc.
Git via Command Palette
The Command Palette (⌘+Shift+P / Ctrl+Shift+P) exposes many Git commands:
Git: Checkout to...— switch branchesGit: Pull/Git: Push— sync with remoteGit: Create Branch— create a new branchGit: Stash/Git: Pop Stash— temporarily save changesGit: View File History— (with GitLens extension) see full commit history
Merge Conflicts
When you encounter merge conflicts, VS Code shows inline buttons:
- Accept Current Change / Accept Incoming Change / Accept Both — click or use Command Palette
- Compare Changes — opens a side-by-side diff view
Recommended Extensions
- GitLens — adds blame annotations, history, and comparison features
- Git Graph — visualize branch history as a graph
Use Case
Using Git shortcuts in VS Code eliminates context-switching to a separate terminal for routine operations. Developers who work primarily in VS Code can stage files, review diffs, create branches, and resolve merge conflicts all within the editor, keeping their focus on the code being changed.