Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What does 'git rebase' do?
It moves or reapplies your branch changes on top of another branch, creating a cleaner, linear history.
Click to reveal answer
beginner
What is the main effect of 'git merge'?
It combines two branches by creating a new commit that joins their histories, preserving all commits as they happened.
Click to reveal answer
intermediate
When should you prefer rebasing over merging?
Use rebase when you want a clean, linear history without extra merge commits, especially before sharing your work.
Click to reveal answer
intermediate
When is merging a better choice than rebasing?
Merge when you want to keep the full history and context of how branches combined, or when working with shared branches.
Click to reveal answer
advanced
What is a risk of rebasing shared branches?
Rebasing shared branches can rewrite history others rely on, causing confusion and conflicts.
Click to reveal answer
What does 'git rebase' do to your commits?
ADeletes them permanently
BMoves them to a new base commit
CCreates a merge commit
DPushes them to remote automatically
✗ Incorrect
'git rebase' moves your commits to a new base, replaying them on top of another branch.
Which command preserves the exact history of both branches?
Agit merge
Bgit rebase
Cgit reset
Dgit stash
✗ Incorrect
'git merge' preserves the full history by creating a merge commit.
When should you avoid rebasing?
AWhen you want to update your branch
BWhen working on a private branch
CWhen you want a clean history
DWhen your branch is shared with others
✗ Incorrect
Avoid rebasing shared branches because it rewrites history others depend on.
What is a benefit of merging?
ACreates a linear history
BAutomatically rebases your branch
CKeeps all branch history intact
DDeletes old commits
✗ Incorrect
Merging keeps all commits and branch history intact.
Which command would you use to update your feature branch with the latest main branch changes without merge commits?
Agit rebase main
Bgit reset main
Cgit merge main
Dgit stash main
✗ Incorrect
'git rebase main' reapplies your commits on top of the latest main branch, avoiding merge commits.
Explain in your own words when you would choose to rebase instead of merge.
Think about how you want your project history to look.
You got /3 concepts.
Describe the risks of rebasing a branch that others are using.
Consider what happens if you change something others already have.
You got /3 concepts.
Practice
(1/5)
1. What is the main reason to use git rebase instead of git merge?
easy
A. To delete the feature branch after merging
B. To keep all branch merge points visible in history
C. To create a clean, linear history without merge commits
D. To automatically resolve all conflicts
Solution
Step 1: Understand rebase purpose
Rebase moves commits to create a straight line history without merge commits.
Step 2: Compare with merge
Merge keeps all branch points and creates merge commits, showing full history.
Final Answer:
To create a clean, linear history without merge commits -> Option C
Quick Check:
Rebase = linear history [OK]
Hint: Rebase = linear history, Merge = full branch history [OK]
Common Mistakes:
Thinking merge creates linear history
Believing rebase deletes branches
Assuming rebase auto-resolves conflicts
2. Which of the following is the correct syntax to rebase your current branch onto main?
easy
A. git rebase origin/main
B. git merge main
C. git checkout main && git rebase
D. git rebase main
Solution
Step 1: Identify rebase command
The command git rebase main rebases the current branch onto main.
Step 2: Check other options
git merge main merges, not rebases; git checkout main && git rebase is incomplete; git rebase origin/main rebases onto remote branch, not local main.
Final Answer:
git rebase main -> Option D
Quick Check:
Rebase syntax = git rebase branch [OK]
Hint: Rebase current branch onto main: git rebase main [OK]
Common Mistakes:
Confusing merge and rebase commands
Using incomplete rebase syntax
Rebasing onto remote branch unintentionally
3. You have a feature branch with 3 commits diverged from main. After running git rebase main, what will the commit history look like?
medium
A. The 3 commits will be replayed on top of the latest main commits
B. The 3 commits will be merged into a single commit on main
C. The 3 commits will be deleted and replaced by main commits
D. The 3 commits will remain unchanged and main will be merged
Solution
Step 1: Understand rebase effect on commits
Rebase takes your commits and re-applies them on top of the target branch, here main.
Step 2: Compare with merge behavior
Merge combines histories with a merge commit; rebase rewrites history to appear linear.
Final Answer:
The 3 commits will be replayed on top of the latest main commits -> Option A
Quick Check:
Rebase = replay commits on new base [OK]
Hint: Rebase replays commits on top of target branch [OK]
Common Mistakes:
Thinking rebase merges commits
Assuming commits are deleted
Confusing merge and rebase results
4. You tried to rebase your branch onto main but got conflicts. What is the correct way to continue after resolving conflicts?
medium
A. Run git rebase --continue after fixing conflicts
B. Run git merge --continue after fixing conflicts
C. Run git commit to finish the rebase
D. Run git rebase --abort to keep the changes
Solution
Step 1: Identify rebase conflict resolution
After fixing conflicts during rebase, you must run git rebase --continue to proceed.
Step 2: Check other options
git merge --continue is for merge conflicts; git commit alone doesn't continue rebase; git rebase --abort cancels rebase.
Final Answer:
Run git rebase --continue after fixing conflicts -> Option A
Quick Check:
Fix conflicts + git rebase --continue [OK]
Hint: After conflict fix in rebase, run git rebase --continue [OK]
Common Mistakes:
Using git merge --continue during rebase
Running git commit instead of rebase continue
Aborting rebase instead of continuing
5. Your team wants to keep a clear record of all branch merges for auditing, but also wants to avoid complex conflict resolution during integration. Which strategy should you choose?
hard
A. Use git rebase to keep history linear and avoid merge commits
B. Use git merge to preserve branch history and avoid rewriting commits
C. Use git rebase and then merge to keep both histories
D. Use git cherry-pick to manually apply commits
Solution
Step 1: Understand audit needs
Keeping a clear record means preserving all branch merge points and history.
Step 2: Compare merge and rebase for conflicts
Merge preserves history and avoids rewriting commits, reducing conflict complexity; rebase rewrites history and can cause conflicts.
Final Answer:
Use git merge to preserve branch history and avoid rewriting commits -> Option B
Quick Check:
Audit needs = merge to keep history [OK]
Hint: Preserve history and audit: choose git merge [OK]