0
0
Gitdevops~20 mins

Merge conflicts why they happen in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Merge Conflict Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why do merge conflicts occur in Git?

Imagine two friends editing the same paragraph in a shared document at the same time. What causes Git to show a merge conflict when combining changes?

ABecause the commit messages are identical in both branches.
BBecause Git lost the internet connection during the merge process.
CBecause one branch deleted the entire file while the other branch added new files.
DBecause both branches changed the same lines differently, so Git cannot decide which change to keep.
Attempts:
2 left
💡 Hint

Think about what happens when two people edit the same exact sentence differently.

💻 Command Output
intermediate
2:00remaining
What is the output when a merge conflict happens?

You run git merge feature but the branches have conflicting changes. What message does Git show?

Git
git merge feature
ANothing happens, the merge is silent.
B
Auto-merging file.txt
CONFLICT (content): Merge conflict in file.txt
Automatic merge failed; fix conflicts and then commit the result.
CError: branch 'feature' does not exist.
DMerge completed successfully with no conflicts.
Attempts:
2 left
💡 Hint

Look for keywords like 'CONFLICT' and 'Automatic merge failed'.

Troubleshoot
advanced
2:00remaining
How to identify conflicting files after a merge conflict?

After a merge conflict, which Git command lists the files that have conflicts needing resolution?

Agit status
Bgit branch
Cgit log
Dgit commit
Attempts:
2 left
💡 Hint

Think about which command shows the current state of your working directory and staged files.

🔀 Workflow
advanced
3:00remaining
What is the correct workflow to resolve a merge conflict?

After a merge conflict, what is the correct sequence of steps to fix and complete the merge?

A4,1,2,3
B1,4,2,3
C4,2,1,3
D2,1,4,3
Attempts:
2 left
💡 Hint

Remember you must start the merge, then fix conflicts, stage changes, and finally commit.

Best Practice
expert
2:30remaining
Why is it best to pull frequently to avoid merge conflicts?

Which reason best explains why regularly pulling changes from the main branch helps reduce merge conflicts?

ABecause Git locks files when you pull, preventing others from editing them.
BBecause pulling deletes your local changes automatically to avoid conflicts.
CBecause it keeps your branch updated with others' changes, reducing the chance of conflicting edits accumulating.
DBecause pulling merges all branches into one automatically without conflicts.
Attempts:
2 left
💡 Hint

Think about how staying updated helps avoid surprises when merging.