Challenge - 5 Problems
Git Merge Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of a fast-forward merge
You have a branch
feature that is ahead of main with new commits. You run git checkout main and then git merge feature. What is the output?Git
git checkout main git merge feature
Attempts:
2 left
💡 Hint
Think about what happens when the target branch has no new commits since the source branch diverged.
✗ Incorrect
When the target branch has no new commits and the source branch is ahead, git performs a fast-forward merge, updating the target branch pointer to the source branch commit. The output shows the commit range and 'Fast-forward'.
💻 Command Output
intermediate2:00remaining
Result of merging with conflicts
You try to merge branch
feature into main, but both branches changed the same lines in a file. What output does git merge feature produce?Git
git checkout main git merge feature
Attempts:
2 left
💡 Hint
Conflicts happen when the same lines are changed differently in both branches.
✗ Incorrect
Git reports the conflicting file and shows a conflict message. It stops the merge and asks you to fix conflicts manually before committing.
❓ Configuration
advanced2:00remaining
Configuring merge strategy for a branch
You want to always use the 'ours' merge strategy when merging the
experimental branch into main. Which git config command sets this behavior?Attempts:
2 left
💡 Hint
The config key for merge options is under the branch name you want to configure.
✗ Incorrect
The mergeoptions config is set per branch and applies when merging into that branch. To always use 'ours' strategy when merging experimental into main, set it under branch.main.mergeoptions.
❓ Troubleshoot
advanced2:00remaining
Cause of 'fatal: refusing to merge unrelated histories' error
You run
git merge feature but get the error fatal: refusing to merge unrelated histories. What is the most likely cause?Attempts:
2 left
💡 Hint
Think about what it means for histories to be unrelated.
✗ Incorrect
This error happens when git tries to merge two branches that do not share any common ancestor commit, often because they come from different repositories initialized separately.
🔀 Workflow
expert3:00remaining
Correct sequence to merge a remote branch with conflict resolution
You want to merge the remote branch
origin/feature into your local main branch and resolve conflicts if any. What is the correct order of commands?Attempts:
2 left
💡 Hint
You must update your remote tracking branches before merging.
✗ Incorrect
First fetch updates remote branches, then checkout main, merge the remote feature branch, and finally resolve conflicts if any before committing.