0
0
Gitdevops~20 mins

Rebase vs merge mental model in Git - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Rebase vs Merge Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the effect of git merge

What happens to the commit history when you perform a git merge of a feature branch into the main branch?

AA new commit is created that combines the changes from both branches, preserving the original branch histories.
BThe feature branch commits are replayed on top of the main branch, creating a linear history.
CThe feature branch is deleted automatically after merging.
DThe main branch is reset to the feature branch's latest commit, discarding previous commits.
Attempts:
2 left
💡 Hint

Think about whether the original commits from the feature branch remain visible after merging.

🧠 Conceptual
intermediate
2:00remaining
Understanding the effect of git rebase

What is the main effect on commit history when you perform a git rebase of a feature branch onto the main branch?

AIt rewrites the feature branch commits to appear as if they were made after the main branch commits, creating a linear history.
BIt deletes the feature branch commits and replaces them with main branch commits.
CIt creates a new merge commit combining both branches.
DIt resets the main branch to the feature branch's latest commit.
Attempts:
2 left
💡 Hint

Consider how the commit timestamps and order change after rebasing.

💻 Command Output
advanced
2:00remaining
Result of git merge with conflicts

You run git merge feature into your main branch. There are conflicting changes in a file. What will git output?

Git
git merge feature
A
error: You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before merging.
B
Merge made by the 'recursive' strategy.
 file.txt | 2 ++
 1 file changed, 2 insertions(+)
C
Auto-merging file.txt
CONFLICT (content): Merge conflict in file.txt
Automatic merge failed; fix conflicts and then commit the result.
Dfatal: Not a git repository (or any of the parent directories): .git
Attempts:
2 left
💡 Hint

Think about what git says when it cannot automatically merge files.

🔀 Workflow
advanced
2:00remaining
Choosing between rebase and merge in a shared repository

You and your team are working on a shared feature branch. Which practice is safer to avoid rewriting history and confusing others?

AUse <code>git rebase</code> frequently on the shared branch to keep it updated.
BUse <code>git merge</code> to integrate changes from main into the feature branch.
CForce push after rebasing the shared branch to update remote history.
DDelete the shared branch and recreate it from main before pushing.
Attempts:
2 left
💡 Hint

Consider what happens when you rewrite history on a branch others use.

Troubleshoot
expert
3:00remaining
Recovering lost commits after a mistaken rebase

You rebased your feature branch but accidentally dropped some commits. How can you find and restore those lost commits?

ADelete the branch and recreate it from main to fix the history.
BRun <code>git merge --abort</code> to undo the rebase and recover commits.
CUse <code>git reset --hard HEAD~3</code> to go back three commits and restore lost work.
DUse <code>git reflog</code> to find the commit hashes and then cherry-pick or reset to them.
Attempts:
2 left
💡 Hint

Think about how git tracks all recent changes, even if they seem lost.