What is the difference between 'git merge' and 'git rebase', and when should each be used in a team workflow?
Quick Revision Summary
Git Merge preserves branch history with merge commits; Git Rebase rewrites commits for a linear history. Never rebase shared public branches.
Interactive Practice Mode
Formulate your thoughts or take notes before revealing the model solution.
Saved automatically
Model Answer & Deep-Dive Explanation
Git Merge:
- Combines changes by creating a new 3-way merge commit connecting the two branches.
- Pros: Non-destructive. Preserves complete, truthful historical record and exact chronological order of commits.
- Cons: Branch commit history can become cluttered with numerous merge commits in large teams.
Git Rebase:
- Rewrites commit history by moving the entire feature branch to begin from the tip of the base branch, re-applying each commit sequentially.
- Pros: Produces a clean, linear git history without unnecessary merge commits.
- Golden Rule: Never rebase commits that have been pushed to a public/shared branch, as it rewrites commit SHAs and causes divergence for teammates.
Interviewer Evaluation Points & Scoring Rubric
- 1 1. Explains 3-way merge commit vs history rewriting. 2. Stresses the golden rule of never rebasing public branches. 3. Recommends team workflow hygiene.
Related Questions in Computer Networks & OS
What is the architectural difference between Docker Containers and Virtual Machines (VMs)?
Beginner level • 1 views
What is the difference between Docker Containerization and Kubernetes Container Orchestration?
Intermediate level • 1 views
How does a process differ from a thread?
Easy level • 1 views
How does a TCP connection differ from an application-level session?
Medium level • 1 views
Why can adding more threads make a CPU-bound service slower?
Medium level • 1 views