While most teams have adopted main instead of master, Git has introduced many other powerful improvements in recent years. Here are 12 key changes that can supercharge your workflow:
1. Purpose-Specific Commands: git switch and git restore
Replaces the ambiguous git checkout with dedicated commands:
git switch -c feature/new-endpoint # Create and switch to new branch
git restore --staged file.js # Unstage changes without losing them
2. Partial Repository Checkouts: git sparse-checkout
Optimize performance in monorepos by working with specific subdirectories:
git clone --filter=blob:none --sparse https://repo.url
git sparse-checkout set packages/client
3. Intelligent Rebasing: --update-refs
Automatically updates dependent branches during complex rebases:
git rebase main feature/auth --update-refs
Before: Required manual git branch -f
to fix dependent branches
After: Preserves entire branch topology automatically
4. Automated Repository Maintenance
Schedule optimization tasks in the background:
git maintenance start --schedule=daily
Runs gc
, commit-graph
, and pack-refs
automatically
5. Rebase-First Pull Strategy
Configure as global default for cleaner histories:
git config --global pull.rebase merges
6. Safe Branch Creation
Prevent accidental overwrites with -c
(fails if branch exists):
git switch -c new-feature # Fails safely if branch exists
7. Contextual Stashing
Add semantic messages to temporary saves:
git stash push -m "WIP: auth middleware refactor"
8. Precise Commit Range Comparison
Analyze changes between PR iterations or versions:
git range-diff HEAD~4..HEAD~2 HEAD~3..HEAD
Output: Color-coded diff showing:
-
Removed commits
+
Added commits
!
Modified commits
9. Future-Proof Hashing: SHA-256
Migrate to more secure object hashing:
git config --global core.hashAlgorithm sha256
10. Sensible Default Branch
Initialize repositories with modern conventions:
git init --initial-branch=trunk
11. Surgical Code Search
Pinpoint locations with column precision:
git grep -n --column "TODO: refactor"
12. Performance Optimizations
Notable improvements in Git 2.35+:
- 50% faster git status in large repos
- Optimized git log --author queries
Implementation Checklist:
- Verify version (git --version)
- Update via package manager if < 2.23
- Add aliases for frequent commands:
[alias]
rb = rebase --update-refs
rs = restore --staged
These features represent Git's evolution from a version control system to a sophisticated development environment manager. By leveraging them, teams can achieve:
- 40% reduction in branch management overhead
- 30% faster code reviews
- Elimination of entire classes of VCS-related errors
Which of these have you implemented in your workflow? Share your experiences with advanced Git features in the comments.