Git Rebase vs Merge
What is the difference between git rebase and git merge? When would you use each?
Git Rebase vs Merge
What is the difference between git rebase and git merge? When would you use each?
Merge creates a new commit combining two branches, preserving history. Rebase rewrites history by moving commits to a new base, creating a linear history. Use merge for shared branches to preserve context; use rebase for feature branches to keep history clean. Never rebase commits that have been pushed to shared branches.
Both achieve branch integration but with different history outcomes. Merge is safer and preserves the complete development timeline. Rebase creates cleaner history but rewrites commits, which can cause issues if others have based work on those commits.
Merge workflow
Rebase workflow
- Rebasing commits that have already been pushed to a shared branch
- Force pushing after rebase without communicating with team members
- Using rebase when merge commits provide valuable context
- What is interactive rebase and when would you use it?
- How do you resolve conflicts during a rebase?
- What is the golden rule of rebasing?