Git Merge Conflicts Quiz

Git
0 Passed
0% acceptance

Don't panic when merges fail. Learn to understand conflict markers, choose the right code changes, and resolve conflicts with confidence.

25 Questions
~50 minutes
1

Question 1

What is the most common reason for a merge conflict in Git?

A
Two people edited different files.
B
Two branches modified the exact same lines of code in the same file differently.
C
One branch added a file and the other branch added a folder.
D
You forgot to run `git fetch` before merging.
2

Question 2

When a conflict occurs, Git modifies the conflicted file to include 'conflict markers'. What does the `<<<<<<< HEAD` marker indicate?

A
The start of the changes from the branch you are merging *in* (incoming).
B
The start of the changes from your current branch (the one you are on).
C
The common ancestor of both branches.
D
The end of the conflict block.
3

Question 3

In a standard conflict block, what does the `=======` line represent?

A
It is a syntax error.
B
It separates the 'current' changes from the 'incoming' changes.
C
It marks the end of the conflict.
D
It shows where the common ancestor code used to be.
4

Question 4

You have manually edited a conflicted file to remove the markers and combine the code correctly. What is the next step to tell Git that the conflict is resolved?

A
Run `git commit`.
B
Run `git merge --continue`.
C
Run `git add <file>`.
D
Run `git resolve <file>`.
5

Question 5

You decide that the merge is too messy and you want to give up and return your project to the state it was in before you ran `git merge`. Which command does this?

A
git merge --undo
B
git merge --abort
C
git reset --hard HEAD
D
git checkout .
6

Question 6

You want to resolve a conflict in `style.css` by completely discarding your local changes and accepting the incoming version from the other branch. Which command does this quickly?

A
git checkout --theirs style.css
B
git checkout --ours style.css
C
git accept-incoming style.css
D
git reset --hard style.css
7

Question 7

What happens if you try to commit a merge while conflict markers (`<<<<<<<`) still exist in a file?

A
Git automatically removes them.
B
Git refuses to commit, warning you that there are unmerged files.
C
Git commits the markers as part of the file content.
D
Git crashes.
8

Question 8

You run `git status` during a conflict. How are the conflicted files listed?

A
Under 'Changes to be committed'.
B
Under 'Unmerged paths' with a status like 'both modified'.
C
Under 'Untracked files'.
D
They are not listed until resolved.
9

Question 9

What is a 'binary conflict'?

A
A conflict involving only 0s and 1s.
B
A conflict where Git cannot show diff markers because the file is not text (e.g., an image or compiled binary).
C
A conflict with only two possible outcomes.
D
A conflict in the `.git` directory.
10

Question 10

You want to see the 'common ancestor' version of the code in the conflict markers (to see what the code looked like *before* either branch changed it). Which config setting enables this?

A
git config merge.conflictstyle diff3
B
git config merge.showAncestor true
C
git config diff.context 3
D
git merge --verbose
11

Question 11

After resolving all conflicts and staging the files, what command finalizes the merge?

A
git merge --finish
B
git commit
C
git push
D
git checkout main
12

Question 12

One branch deleted a file, while the other branch modified it. What happens when you merge?

A
Git automatically keeps the modified file.
B
Git automatically deletes the file.
C
Git raises a 'modify/delete' conflict.
D
Git creates two files.
13

Question 13

You are using a graphical merge tool (like KDiff3 or Meld) configured with Git. Which command launches this tool to help you resolve conflicts?

A
git tool
B
git mergetool
C
git resolve --gui
D
git open
14

Question 14

What does `git checkout --ours file.txt` do during a conflict?

A
It keeps the version from the branch you are merging *in*.
B
It keeps the version from the branch you were on *before* the merge started.
C
It keeps the common ancestor version.
D
It combines both versions automatically.
15

Question 15

You have enabled `rerere` (Reuse Recorded Resolution). What does this feature do?

A
It automatically resolves simple whitespace conflicts.
B
It remembers how you resolved a specific conflict and automatically applies the same resolution if it encounters the same conflict again.
C
It forces all merges to be fast-forward.
D
It backs up your resolutions to the cloud.
16

Question 16

Which command shows the list of commits that are unique to the 'ours' branch and the 'theirs' branch involved in the conflict?

A
git log --merge
B
git log --conflict
C
git show-branch
D
git status -v
17

Question 17

You want to merge `feature` into `main`, but you want to prioritize your changes in `main` for *all* conflicts without being asked. Which command does this?

A
git merge -Xours feature
B
git merge -s ours feature
C
git merge --force feature
D
git merge --strategy-option=theirs feature
18

Question 18

What is the difference between `git merge -s ours` and `git merge -Xours`?

A
They are the same.
B
`-s ours` creates a merge commit but ignores ALL changes from the other branch. `-Xours` merges normally but resolves CONFLICTS by choosing 'ours'.
C
`-s ours` is for submodules, `-Xours` is for files.
D
`-Xours` is a typo.
19

Question 19

You accidentally staged a file with conflict markers still in it. How can you unstage it to fix it?

A
git reset HEAD <file>
B
git restore --staged <file>
C
git rm --cached <file>
D
Both A and B work.
20

Question 20

Why might Git refuse to start a merge in the first place?

A
Because you have uncommitted changes in your working directory that would be overwritten by the merge.
B
Because the branch names are too long.
C
Because it is raining.
D
Because the remote server is down.
21

Question 21

You are resolving a conflict and want to see the diff of just the conflicting changes again (after you might have messed up the markers). How can you recreate the conflict markers in the file?

A
git checkout -m <file>
B
git reset --hard
C
git merge --retry
D
git diff --recreate
22

Question 22

What does the `>>>>>>>` marker usually differ from the `<<<<<<<` marker in terms of content?

A
It contains the branch name or commit SHA of the incoming change.
B
It contains the author name.
C
It contains the timestamp.
D
It is always empty.
23

Question 23

You want to merge `dev` into `main`, but you know `dev` has many whitespace changes that conflict with `main`. How can you tell Git to ignore whitespace conflicts?

A
git merge -Xignore-all-space dev
B
git merge --ignore-whitespace dev
C
git config core.whitespace false
D
You cannot ignore whitespace in a merge.
24

Question 24

If a merge results in a conflict, in which state is the repository left?

A
A special 'merging' state where HEAD is locked.
B
The repository is corrupted.
C
It reverts to the state before the merge automatically.
D
It enters a 'detached HEAD' state.
25

Question 25

What is the 'recursive' merge strategy?

A
It is the default strategy for merging two branches. It can handle complex merges with multiple common ancestors.
B
It keeps merging until the stack overflows.
C
It is a strategy that only looks at the last commit.
D
It is a deprecated strategy.