0
0
Gitdevops~20 mins

git merge command - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Merge Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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
A
Updating abc1234..def5678
Fast-forward
B
Auto-merging file.txt
CONFLICT (content): Merge conflict in file.txt
CAlready up to date.
Derror: You have unmerged files.
Attempts:
2 left
💡 Hint
Think about what happens when the target branch has no new commits since the source branch diverged.
💻 Command Output
intermediate
2: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
A
Auto-merging file.txt
CONFLICT (content): Merge conflict in file.txt
Automatic merge failed; fix conflicts and then commit the result.
BAlready up to date.
Cerror: Your local changes to the following files would be overwritten by merge
DFast-forward
Attempts:
2 left
💡 Hint
Conflicts happen when the same lines are changed differently in both branches.
Configuration
advanced
2: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?
Agit config branch.main.merge '--strategy=ours'
Bgit config branch.experimental.mergeoptions '--strategy=ours'
Cgit config branch.experimental.merge '--strategy=ours'
Dgit config branch.main.mergeoptions '--strategy=ours'
Attempts:
2 left
💡 Hint
The config key for merge options is under the branch name you want to configure.
Troubleshoot
advanced
2: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?
AThere are uncommitted changes in the working directory.
BThe branches come from repositories with no common commit history.
CThe feature branch has merge conflicts.
DThe main branch is already up to date.
Attempts:
2 left
💡 Hint
Think about what it means for histories to be unrelated.
🔀 Workflow
expert
3: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?
A1,3,2,4
B1,2,3,4
C2,1,3,4
D2,3,1,4
Attempts:
2 left
💡 Hint
You must update your remote tracking branches before merging.