bashintermediate
Git Rebase Workflow Example
Step-by-step git rebase workflow to keep feature branches up to date with main branch cleanly.
bashPress ⌘/Ctrl + Shift + C to copy
# Update main branch
git checkout main
git pull origin main
# Rebase feature branch onto latest main
git checkout feature/my-feature
git rebase main
# If conflicts arise during rebase:
# 1. Fix conflicts in the files
# 2. Stage the resolved files
git add .
# 3. Continue the rebase
git rebase --continue
# To abort rebase and return to original state
git rebase --abort
# After successful rebase, force push (feature branch only)
git push --force-with-lease origin feature/my-feature
# Rebase last 3 commits onto main
git rebase --onto main HEAD~3Use Cases
- Keeping feature branches linear with main
- Cleaning up commit history before merging
- Avoiding merge commits in pull requests
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
bashadvanced
Git Rebase Strategies Guide
Advanced rebase strategies for cleaning history including onto, autosquash, and conflict resolution.
Best for: Cleaning commit history before merging
#git#rebase
bashintermediate
Git Cherry-Pick Commits Example
Apply specific commits from one branch to another using cherry-pick with conflict resolution.
Best for: Backporting bug fixes to release branches
#git#cherry-pick
bashintermediate
Squash Multiple Git Commits
Interactive rebase to squash multiple commits into one clean commit before merging a feature branch.
Best for: Cleaning up messy commit history
#git#squash
bashbeginner
Git Stash Usage Examples
Save, list, apply, and manage uncommitted changes with git stash for quick context switching.
Best for: Switching branches with uncommitted work
#git#stash