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 rebasing do to your commit history in Git?
Rebasing moves your branch's commits to start from the latest commit of the target branch, creating a straight, linear sequence of commits.
Click to reveal answer
intermediate
How does rebasing differ from merging in terms of commit history?
Merging combines branches by creating a new merge commit, preserving the branch structure, while rebasing rewrites commits to create a linear history without merge commits.
Click to reveal answer
beginner
Why is a linear history beneficial in Git?
A linear history is easier to read and understand because it shows a clear, step-by-step progression of changes without complex branching paths.
Click to reveal answer
intermediate
What happens to your commits during a rebase?
Your commits are temporarily saved, the branch is moved to the new base commit, then your commits are reapplied one by one on top of that base.
Click to reveal answer
intermediate
Can rebasing change commit hashes? Why?
Yes, because rebasing creates new commits based on the old ones but with a different parent, resulting in new commit hashes.
Click to reveal answer
What is the main effect of rebasing a branch in Git?
AIt deletes all commits on the branch.
BIt creates a linear commit history by moving commits.
CIt merges two branches with a merge commit.
DIt creates a new branch without commits.
✗ Incorrect
Rebasing moves commits to a new base, making the history linear.
Which Git command rewrites commit history to be linear?
Agit merge
Bgit stash
Cgit clone
Dgit rebase
✗ Incorrect
git rebase reapplies commits on top of another base commit, creating linear history.
What does rebasing do to commit hashes?
AChanges them because commits are recreated
BDeletes them
CKeeps them the same
DMerges them
✗ Incorrect
Rebasing creates new commits with new hashes because the parent commit changes.
Why might developers prefer rebasing over merging?
ATo delete branches
BTo create more merge commits
CTo keep a clean, linear history
DTo avoid pushing changes
✗ Incorrect
Rebasing keeps history simple and linear, making it easier to follow.
What happens to your commits during a rebase?
AThey are saved, branch is moved, then reapplied
BThey are deleted permanently
CThey are merged into one commit
DThey are pushed to remote automatically
✗ Incorrect
Git saves your commits, moves the branch, then reapplies commits on top.
Explain in your own words why rebasing creates a linear history in Git.
Think about how commits are moved and reapplied on top of another branch.
You got /5 concepts.
Describe the difference between rebasing and merging regarding commit history.
Consider how each command affects the shape of the commit graph.
You got /5 concepts.
Practice
(1/5)
1. What is the main reason rebasing creates a linear history in Git?
easy
A. It creates a new branch automatically
B. It merges all branches into one commit
C. It deletes all previous commits
D. It moves your commits on top of the latest commit from the target branch
Solution
Step 1: Understand what rebasing does
Rebasing takes your commits and places them on top of another branch's latest commit, replaying them in order.
Step 2: Effect on commit history
This action removes the branching structure by making your commits appear as if they were made after the latest commit on the target branch, creating a straight line.
Final Answer:
It moves your commits on top of the latest commit from the target branch -> Option D
Quick Check:
Rebase = replay commits on top [OK]
Hint: Rebase replays commits on latest branch commit [OK]
Common Mistakes:
Thinking rebase merges commits into one
Believing rebase deletes old commits
Confusing rebase with branch creation
2. Which Git command syntax correctly rebases the current branch onto main?
easy
A. git merge main
B. git rebase main
C. git rebase -m main
D. git checkout main rebase
Solution
Step 1: Identify the correct rebase command
The correct syntax to rebase the current branch onto main is git rebase main.
Step 2: Check other options for errors
git merge main merges instead of rebasing; git rebase -m main is invalid syntax; git checkout main rebase is not a valid command.
Final Answer:
git rebase main -> Option B
Quick Check:
Rebase syntax = git rebase branch [OK]
Hint: Use 'git rebase branchname' to rebase [OK]
Common Mistakes:
Using merge instead of rebase
Adding invalid flags like -m
Combining checkout and rebase incorrectly
3. Given this commit history:
main: A --- B --- C feature: A --- B --- D --- E
After running git rebase main on feature, what will the new commit history look like?
medium
A. main: A --- B --- C feature: A --- B --- C --- D' --- E'
B. main: A --- B --- C feature: D --- E
C. main: A --- B --- C --- D --- E feature: A --- B --- C --- D --- E
D. main: A --- B --- C feature: A --- B --- D --- E
Solution
Step 1: Understand rebase effect on commits
Rebasing feature onto main moves commits D and E to be based on C, replaying them as new commits D' and E'.
Step 2: Visualize new commit history
The main branch remains unchanged. The feature branch now appears as if commits D' and E' were made after C, creating a linear history.
Final Answer:
main: A --- B --- C feature: A --- B --- C --- D' --- E' -> Option A
Quick Check:
Rebase = replay commits on main tip [OK]
Hint: Rebase replays commits after target branch tip [OK]
Common Mistakes:
Assuming commits stay unchanged
Thinking rebase merges commits
Ignoring that rebased commits get new IDs
4. You tried to rebase your branch but got a conflict error. What is the best way to fix this and continue the rebase?
medium
A. Abort the rebase and start over with git rebase --abort
B. Run git merge --continue to resolve conflicts
C. Fix the conflicts manually, then run git rebase --continue
D. Delete the branch and create a new one
Solution
Step 1: Understand rebase conflict handling
When a conflict occurs during rebase, Git pauses and lets you fix conflicts manually in the files.
Step 2: Continue rebase after fixing conflicts
After resolving conflicts, you must run git rebase --continue to proceed with the rebase process.
Final Answer:
Fix the conflicts manually, then run git rebase --continue -> Option C
Quick Check:
Fix conflicts + git rebase --continue [OK]
Hint: Fix conflicts then run 'git rebase --continue' [OK]
Common Mistakes:
Using merge commands during rebase
Aborting instead of continuing after fix
Deleting branch unnecessarily
5. You have two feature branches, feature1 and feature2, both branched from main. feature1 was rebased onto main and pushed. Now you want to rebase feature2 onto feature1. What is the main benefit of this approach?
hard
A. It creates a linear history combining both features without merge commits
B. It deletes feature1 branch automatically
C. It merges feature2 into main directly
D. It resets feature2 to main ignoring feature1
Solution
Step 1: Understand rebasing one feature branch onto another
Rebasing feature2 onto feature1 places feature2's commits on top of feature1, making the history linear.
Step 2: Benefit of linear history
This avoids merge commits and shows a clear sequence of changes, making history easier to read and understand.
Final Answer:
It creates a linear history combining both features without merge commits -> Option A
Quick Check:
Rebase feature2 on feature1 = linear combined history [OK]
Hint: Rebase feature2 on feature1 for clean linear history [OK]