Merge Conflicts Beginner Quiz
30 questions on Resolving Merge Conflicts.
Question 1: What is a Merge Conflict in Git?
- A. When Git deletes a file accidentally
- B. When two branches have modified the exact same lines in a file, and Git cannot automatically decide which version to keep β (correct answer)
- C. When the GitHub server crashes
- D. When you type the wrong password
Explanation: Git is very smart at merging files, but if Developer A changes line 10 to "Blue" and Developer B changes line 10 to "Red", Git halts the merge and asks a human to resolve the conflict.
Question 2: When do merge conflicts most commonly occur?
- A. While cloning a repository
- B. During a
git commit
- C. During a
git merge or git pull β (correct answer)
- D. While initializing a new repository
Explanation: Conflicts only happen when you attempt to integrate code from one branch (or remote server) into your current branch.
Question 3: How does Git notify you that a merge conflict has occurred?
- A. It sends you an email
- B. It prints a "CONFLICT (content): Merge conflict in [filename]" message in the terminal and halts the merge β (correct answer)
- C. It automatically deletes the conflicting file
- D. It randomly chooses one version and continues
Explanation: Git stops the automatic merge process immediately, leaving the conflicting files modified in your working directory for you to fix.
Question 4: What are "Conflict Markers"?
- A. Red text in the terminal
- B. Special symbols (like
<<<<<<<, =======, >>>>>>>) injected directly into your file by Git to show exactly where the overlapping changes are β (correct answer)
- C. Error logs in the
.git folder
- D. A feature in GitHub
Explanation: These markers isolate the current branch's code from the incoming branch's code, so you can clearly see the differences.
Question 5: In a conflict marker, what does <<<<<<< HEAD represent?
- A. The top of the file
- B. The code from the branch you are currently on (your local changes) β (correct answer)
- C. The code from the remote server
- D. A syntax error
Explanation: HEAD represents the state of the branch you had checked out when you initiated the merge.
Question 6: In a conflict marker, what does the ======= symbol represent?
- A. An equals sign in the code
- B. The divider separating your local code from the incoming code β (correct answer)
- C. The end of the conflict
- D. A deleted line
Explanation: Everything above ======= is from your branch. Everything below it is from the branch you are trying to merge in.
Question 7: What does the >>>>>>> branch-name marker represent?
- A. The end of the conflicting code block, showing the code from the branch being merged IN β (correct answer)
- B. A directional arrow in the code
- C. The new name of the file
- D. A push command
Explanation: This marker closes the conflict block and tells you exactly which incoming branch caused the conflict.
Question 8: What must you physically do to resolve the conflict in the file?
- A. Run
git conflict --resolve
- B. Edit the file to keep the code you want, and completely delete the
<<<<<<<, =======, and >>>>>>> markers β (correct answer)
- C. Delete the file
- D. Push the file to GitHub immediately
Explanation: Git expects the file to look exactly how it should run in production. If you leave the markers in the file, your code will break (syntax error).
Question 9: After you have edited the file and removed the conflict markers, what is the next step to finish the merge?
- A. Run
git commit -m "Resolved conflicts" without staging
- B. Stage the file using
git add [filename], then run git commit to finalize the merge β (correct answer)
- C. Run
git push
- D. Run
git stop-merge
Explanation: Using git add tells Git "I have resolved the conflict for this file." Once all files are added, committing finishes the merge state.
Question 10: How can you find out which files currently have unresolved merge conflicts?
- A.
git log
- B.
git show
- C.
git status β (correct answer)
- D.
git find-conflicts
Explanation: git status will clearly list files under the heading "Unmerged paths:", indicating they still need conflict resolution.
Question 11: If you get overwhelmed by a merge conflict and want to cancel the merge entirely, returning to your previous state, what command do you use?
- A.
git merge --abort β (correct answer)
- B.
git cancel
- C.
git revert
- D.
git reset --hard
Explanation: git merge --abort is a lifesaver. It stops the merge process and puts your working directory exactly back to how it was before you typed git merge.
Question 12: How do modern Code Editors (like VS Code) help with merge conflicts?
- A. They prevent conflicts from happening
- B. They provide visual highlights and clickable buttons (like "Accept Current Change" or "Accept Both Changes") to resolve markers automatically β (correct answer)
- C. They delete conflicting files
- D. They email the other developer
Explanation: Modern IDEs parse the <<<<<<< markers and overlay a GUI that makes resolving conflicts a one-click process.
Question 13: Can a merge conflict happen if one person modifies a file, and another person deletes that exact same file?
- A. No, Git will just delete it
- B. Yes, this is known as a "Modify/Delete" conflict β (correct answer)
- C. No, Git will restore it automatically
- D. Only on Windows
Explanation: Git doesn't know if it should keep the modifications or honor the deletion, so it halts and asks you what to do.
Question 14: Can a merge conflict happen if you and a teammate edit completely different files?
- A. Yes
- B. No, Git will auto-merge them perfectly β (correct answer)
- C. Only if the files are in the same folder
- D. Only if the files have the same extension
Explanation: If you edit index.html and your teammate edits style.css, Git automatically merges the changes without any conflicts.
Question 15: Can a merge conflict happen if you and a teammate edit the exact same file, but on different lines (e.g., line 10 and line 500)?
- A. Yes
- B. No, Git is usually smart enough to merge non-overlapping changes in the same file automatically β (correct answer)
- C. Only in Python
- D. Only on GitHub
Explanation: Git merges changes line-by-line. If the edited lines are far apart and don't overlap, it auto-merges them seamlessly.
Question 16: What does it mean to "Accept Both Changes" during a conflict?
- A. You tell Git to keep your code and put the incoming code immediately below it in the file β (correct answer)
- B. You keep your code and delete the incoming code
- C. You create two separate files
- D. You push to two different branches
Explanation: Sometimes both additions are valid (e.g., you added a new function, and your teammate added a different new function on the same line). Accepting both keeps both functions.
Question 17: What does git log --merge do?
- A. Merges the log files
- B. Shows only the commits that are involved in the current merge conflict β (correct answer)
- C. Deletes the merge history
- D. Forces a merge
Explanation: This is helpful to understand *why* the conflict is happening by seeing the exact commits that caused the divergent history.
Question 18: What is a "rebase conflict"?
- A. A conflict that happens when downloading Git
- B. A conflict that occurs during
git rebase because Git is applying your commits one by one on top of the new base β (correct answer)
- C. A conflict on GitHub
- D. A server error
Explanation: Unlike a standard merge (which resolves all conflicts at once), a rebase might require you to resolve conflicts sequentially as each commit is re-applied.
Question 19: After resolving a conflict during a git rebase, what command do you use to proceed?
- A.
git commit
- B.
git merge --continue
- C.
git rebase --continue β (correct answer)
- D.
git push
Explanation: During a rebase, you do NOT create a merge commit. You git add the resolved files and use --continue to move to the next commit.
Question 20: If you are stuck in a bad rebase conflict and want to escape, what do you type?
- A.
git merge --abort
- B.
git rebase --abort β (correct answer)
- C.
git cancel
- D.
git stop
Explanation: Just like --abort for merges, this cancels the rebase process and returns your branch to its original state.
Question 21: What is a visual "Diff Tool"?
- A. A tool to measure download speed
- B. A third-party GUI application (like Beyond Compare or KDiff3) that helps visualize and resolve conflicts side-by-side β (correct answer)
- C. A GitHub Action
- D. A syntax checker
Explanation: You can configure Git to open these tools automatically using the git mergetool command.
Question 22: What does the git mergetool command do?
- A. Automatically resolves the conflict
- B. Launches your configured visual diff/merge GUI to help you resolve the conflict β (correct answer)
- C. Installs a new Git version
- D. Merges the
main branch
Explanation: If you prefer a 3-way split-screen GUI over text-based markers, mergetool launches programs like Meld, KDiff3, or VS Code.
Question 23: How can frequent communication prevent merge conflicts?
- A. It cannot prevent them
- B. By letting teammates know which files you are refactoring so they avoid working on the same files simultaneously β (correct answer)
- C. By sharing passwords
- D. By emailing code snippets
Explanation: Good team communication and dividing work efficiently is the best defense against constant merge conflicts.
Question 24: Why is "pulling frequently" considered a best practice to avoid massive conflicts?
- A. It makes the internet faster
- B. It ensures your local branch stays up-to-date with
main, meaning conflicts are small and resolved incrementally rather than piling up for weeks β (correct answer)
- C. It backs up your code
- D. It deletes old branches
Explanation: If you wait a month to pull main, the conflicts will be a nightmare. Pulling daily keeps conflicts manageable.
Question 25: Can a merge conflict happen on GitHub when creating a Pull Request?
- A. Yes, GitHub will show "Cannot merge automatically" β (correct answer)
- B. No, GitHub automatically deletes conflicting files
- C. No, conflicts only happen in the terminal
- D. Yes, but it resolves it automatically
Explanation: GitHub detects the conflict between your branch and main. You must resolve it (either locally or via GitHub's web editor) before the "Merge" button turns green.
Question 26: If you get a conflict, and you know your incoming branch's code is 100% correct and you want to overwrite all local changes without reviewing markers, what strategy can you use?
- A.
git merge -X theirs β (correct answer)
- B.
git merge --force
- C.
git pull --overwrite
- D.
git reset --hard
Explanation: Passing -X theirs (or -X ours) tells Git's merge strategy to automatically favor one side over the other in the event of a conflict.
Question 27: What happens to the .orig files that appear in your directory after using a mergetool?
- A. They are essential system files
- B. They are backup copies of the file before conflict resolution, generated by Git just in case you mess up β (correct answer)
- C. They are viruses
- D. They contain the Git history
Explanation: You can safely delete these .orig files once the conflict is resolved. You can also configure Git not to create them (git config --global mergetool.keepBackup false).
Question 28: If two developers rename the same file to two different names, what kind of conflict is this?
- A. A Modify/Delete conflict
- B. A Rename/Rename conflict β (correct answer)
- C. A Content conflict
- D. A Directory conflict
Explanation: Git will pause the merge and ask you which of the two new file names you actually want to keep.
Question 29: What is a "3-way merge"?
- A. Merging three branches at once
- B. A merge that looks at your branch, the incoming branch, AND the common ancestor commit where the two branches originally diverged β (correct answer)
- C. A merge done by three developers
- D. A merge taking three steps
Explanation: Git uses the common ancestor (the "base") to intelligently figure out who changed what. Without the base, Git wouldn't know which version is the "newer" one.
Question 30: If you resolve a conflict and commit, but realize you made a terrible mistake in the resolution, how can you undo the merge commit?
- A.
git revert -m 1 [merge_commit_hash] β (correct answer)
- B.
git delete merge
- C.
git cancel
- D. You cannot undo a merge
Explanation: Reverting a merge commit is complex because Git needs to know which "parent" line of history to keep (mainline vs feature). -m 1 specifies the mainline parent.