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 is a merge conflict in Git?
A merge conflict happens when Git cannot automatically combine changes from two branches because the same part of a file was changed differently in each branch.
Click to reveal answer
beginner
How does Git mark the conflicting areas in a file?
Git uses special markers like <<<<<<<, =======, and >>>>>>> to show the conflicting parts from each branch inside the file.
Click to reveal answer
beginner
What is the first step to resolve a merge conflict?
Open the conflicted file, find the conflict markers, and decide how to combine or choose between the changes.
Click to reveal answer
beginner
Which Git command do you use to mark a conflict as resolved after editing?
Use git add <filename> to mark the conflict as resolved before committing.
Click to reveal answer
beginner
What command finalizes the merge after resolving conflicts?
Run git commit to complete the merge once all conflicts are resolved and staged.
Click to reveal answer
What does Git use to show conflicting changes inside a file?
ASeparate files for conflicts
BColor codes only
CNo indication, manual check needed
DSpecial markers like <<<<<<< and >>>>>>>
✗ Incorrect
Git inserts markers like <<<<<<<, =======, and >>>>>>> to highlight conflicting sections.
After fixing a merge conflict in a file, what is the next Git command to run?
Agit clone
Bgit add <filename>
Cgit push
Dgit merge
✗ Incorrect
You must stage the resolved file with git add before committing.
What causes a merge conflict in Git?
ATwo branches change the same lines differently
BBranches have different names
CFiles are too large
DNo internet connection
✗ Incorrect
Conflicts occur when the same lines in a file are changed differently in two branches.
Which command completes the merge after resolving conflicts?
Agit commit
Bgit status
Cgit branch
Dgit reset
✗ Incorrect
git commit finalizes the merge after all conflicts are resolved and staged.
If you want to abort a merge and return to the previous state, which command do you use?
Agit reset --hard
Bgit checkout master
Cgit merge --abort
Dgit stash
✗ Incorrect
git merge --abort cancels the merge and restores the state before merging.
Explain the steps you take to resolve a merge conflict in Git.
Think about what Git shows you and how you fix it step by step.
You got /6 concepts.
What are the common causes of merge conflicts and how can you avoid them?
Consider why conflicts happen and good teamwork habits.
You got /5 concepts.
Practice
(1/5)
1. What does a merge conflict in Git mean?
easy
A. Git found changes in the same file that it cannot combine automatically.
B. Git has successfully merged all changes without any issues.
C. Git deleted a file during the merge process.
D. Git created a new branch automatically.
Solution
Step 1: Understand merge conflict meaning
A merge conflict happens when Git sees changes in the same part of a file from different branches and cannot decide which to keep.
Step 2: Identify what Git does in this case
Git stops the merge and marks the conflict in the file for you to fix manually.
Final Answer:
Git found changes in the same file that it cannot combine automatically. -> Option A
Quick Check:
Merge conflict = conflicting changes in same file [OK]
Hint: Merge conflict means manual fix needed for overlapping changes [OK]
Common Mistakes:
Thinking Git merges all changes automatically
Confusing conflict with branch creation
Assuming files are deleted automatically
2. Which Git command is used to mark a conflict as resolved after editing the file?
easy
A. git add <file>
B. git commit -m 'resolve conflict'
C. git merge --continue
D. git checkout --conflict
Solution
Step 1: Identify how to tell Git conflict is fixed
After editing the conflicted file, you must stage it to tell Git the conflict is resolved.
Step 2: Choose the correct command to stage files
The command to stage files is git add <file>.
Final Answer:
git add <file> -> Option A
Quick Check:
Stage resolved file with git add [OK]
Hint: Use git add to mark conflict resolved before commit [OK]
Common Mistakes:
Trying to commit before staging resolved files
Using git merge --continue without staging
Using invalid commands like git checkout --conflict
3. Given this conflict marker in a file after a merge:
<<<<<<< HEAD
Line A
=======
Line B
>>>>>>> feature-branch
What will the file content be after you keep only the changes from the feature-branch and stage the file?
medium
A. Line A
B. Line B
C. <<<<<<< HEAD
Line A
=======
Line B
>>>>>>> feature-branch
D. Line A
Line B
Solution
Step 1: Understand conflict markers
The lines between <<<<<<< HEAD and ======= are from current branch; lines between ======= and >>>>>>> feature-branch are from the other branch.
Step 2: Keep only feature-branch changes
To keep only feature-branch changes, remove the markers and the HEAD section, leaving just 'Line B'.
4. You tried to merge a branch but Git reports conflicts. You edited the files but forgot to stage them before committing. What happens if you run git commit now?
medium
A. Git commits the merge with unresolved conflicts included.
B. Git automatically stages and commits the resolved files.
C. Git refuses to commit and shows an error about unmerged paths.
D. Git aborts the merge and resets to previous state.
Solution
Step 1: Understand commit behavior during merge conflicts
Git requires you to stage resolved files before committing a merge. If files are not staged, Git sees conflicts as unresolved.
Step 2: What happens when committing without staging
Git will refuse to commit and show an error about unmerged paths, preventing incomplete merges.
Final Answer:
Git refuses to commit and shows an error about unmerged paths. -> Option C
Quick Check:
Commit without staging resolved files = error [OK]
Hint: Always git add resolved files before git commit [OK]
Common Mistakes:
Assuming git commit auto-stages files
Thinking Git commits partial merges
Expecting merge to abort automatically
5. You have a file with multiple merge conflicts from two branches. You want to keep all changes from both branches but Git shows conflicts. What is the best way to resolve this?
hard
A. Run git reset --hard to discard all changes and merge again.
B. Use git merge --abort to cancel the merge and try again.
C. Delete the file and create a new one with combined content.
D. Manually edit the file to combine both changes, remove conflict markers, then stage and commit.
Solution
Step 1: Understand the goal to keep all changes
Since you want to keep both branches' changes, you must manually combine them in the file.
Step 2: How to resolve conflicts properly
Edit the file to merge both changes, remove conflict markers, then stage with git add and commit the merge.
Final Answer:
Manually edit the file to combine both changes, remove conflict markers, then stage and commit. -> Option D