# Advanced Git Techniques
Git is more than just `git add` and `git commit`. Let's explore advanced techniques.
## Interactive Rebase
Clean up your commit history before pushing:
```bash
# Rebase last 3 commits interactively
git rebase -i HEAD~3
# In the editor:
pick abc123 Add feature
squash def456 Fix typo
reword ghi789 Update documentation
```
## Cherry-Picking
Apply specific commits from one branch to another:
```bash
# Cherry-pick a single commit
git cherry-pick abc123
# Cherry-pick multiple commits
git cherry-pick abc123 def456 ghi789
```
## Stashing with Context
Save work in progress with a descriptive message:
```bash
# Stash with message
git stash push -m "WIP: user authentication feature"
# List stashes
git stash list
# Apply specific stash
git stash apply stash@{1}
```
## Bisect for Bug Hunting
Find the commit that introduced a bug:
```bash
git bisect start
git bisect bad HEAD
git bisect good v1.0.0
# Git will check out commits for you to test
git bisect good # or bad
git bisect reset
```
Tools
10 min readJanuary 25, 2024
Advanced Git Techniques Every Developer Should Know
Master advanced Git workflows including rebasing, cherry-picking, and interactive staging.
GitVersion ControlDevOpsCLI
M
Michael Zhang
DevOps Engineer