VS Code isn't just a text editor - it's a complete Git command center that makes version control visual, intuitive, and powerful.
# In VS Code Terminal (Ctrl+`) git --version git version 2.39.0 # If not installed, download from git-scm.com
# Open Command Palette: Ctrl+Shift+P (Cmd+Shift+P on Mac) > Git: Configure User Name > Git: Configure User Email # Or use terminal: git config --global user.name "Your Name" git config --global user.email "you@example.com"
# Method 1: Status Bar Click branch name (bottom-left) → Create new branch # Method 2: Command Palette Ctrl+Shift+P → "Git: Create Branch" # Method 3: Source Control ... menu → Branch → Create Branch
# Stage individual files Click + next to filename # Stage all changes Click + next to "Changes" header # Commit with message Type message → Ctrl+Enter # Amend last commit ... menu → Commit → Amend
# Push/Pull in one click Click sync icon (↻) in status bar # Pull only ... menu → Pull # Push only ... menu → Push # Push to specific remote ... menu → Push to...
# View file changes Click on modified file in Source Control # Inline diff in editor Click gutter indicators # Compare with any commit Right-click file → Open Timeline # Side-by-side diff Settings → Diff Editor → Side by Side
1. Open Extensions (Ctrl+Shift+X) 2. Search "GitHub Pull Requests and Issues" 3. Click Install 4. Sign in to GitHub when prompted 5. Authorize VS Code # Now you can: - See PR status in status bar - Review PRs without leaving VS Code - Create PRs from current branch - Link commits to issues: "fixes #123"
GitLens is the ultimate VS Code extension for Git power users, adding blame annotations, commit search, and visualization.
John Doe, 3 days ago • Fix calculation error return total * 1.08; // Added tax
Right-click file → Open File History - See all commits - Compare versions - Restore old versions
Search commits by: - Message - Author - File - Changes
- Commit graph - Branch comparisons - Contributors - Heatmaps
VS Code makes interactive rebase visual and intuitive!
# Start interactive rebase 1. Open Command Palette (Ctrl+Shift+P) 2. "Git: Rebase Branch..." 3. Select target branch # VS Code opens a visual editor: pick abc123 Add feature squash def456 Fix typo ← Change 'pick' to 'squash' reword ghi789 Update docs ← Change commit message # Save and close to execute rebase
| Ctrl+Shift+G | Open Git panel |
| Ctrl+Enter | Commit staged |
| Ctrl+Shift+P | Command palette |
| Ctrl+K Ctrl+Alt+S | Stage selected lines |
| Alt+←/→ | Navigate history |
// settings.json { "git.enableSmartCommit": true, "git.autofetch": true, "git.confirmSync": false, "git.postCommitCommand": "push", "git.pruneOnFetch": true }
Solution:
1. Install Git from git-scm.com
2. Restart VS Code
3. If still not working:
Settings → Search "git.path"
Set to Git installation path
(e.g., C:\Program Files\Git\bin\git.exe)
Solution:
1. Clear credentials:
Windows: Credential Manager
Mac: Keychain Access
Linux: git config --global credential.helper ""
2. Re-authenticate:
Ctrl+Shift+P → "GitHub: Sign Out"
Then sign in again
Solution:
1. Refresh Source Control: Click refresh icon
2. Check .gitignore file
3. Initialize repository if needed:
Ctrl+Shift+P → "Git: Initialize Repository"
4. Check Git output:
Output panel → Select "Git" from dropdown
Supercharges Git - blame, history, comparisons
ext install eamodio.gitlens
Visual commit history and branch management
ext install mhutchie.git-graph
Manage PRs without leaving VS Code
ext install GitHub.vscode-pull-request-github
Helps write standardized commit messages
ext install vivaxy.vscode-conventional-commits
Add emojis to commit messages
ext install seatonjiang.git-emoji
View and search file/line history
ext install donjayamanne.githistory
1. Pull latest changes: Click Sync button (↻)
2. Create feature branch:
- Click "main" in status bar
- Select "Create new branch"
- Name: "feature/user-authentication"
3. Make changes:
- Edit files normally
- See changes in Source Control panel
- Green = added, Blue = modified, Red = deleted
4. Stage changes:
- Review each file (click to see diff)
- Stage files with + button
- Or stage individual lines (right-click)
5. Commit with message:
- Type: "feat: add user login functionality"
- Press Ctrl+Enter
6. Push to GitHub:
- Click Publish Branch (first time)
- Or click Sync for updates
7. Create Pull Request:
- Click "Create Pull Request" in Source Control
- Fill in description
- Submit for review
8. After approval, merge:
- Switch to main: Click branch → main
- Pull latest: Click Sync
- Delete old branch locally
VS Code + Git + GitHub = The ultimate development workflow
Keep these handy while coding:
Remember: The best way to learn is by doing. Start using VS Code's Git features in your next project!