⚡ ~/naveed Interview Prep
⚡ Portfolio Home 👤 About Naveed Bio & Credentials 📫 Contact Naveed Get In Touch ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 1,000+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →
← Back to All Git & Branching Workflows Interview Questions Scenario 3 of 52 in Git & Branching Workflows
Senior DevOps / SRE [L2] Git Branching, Merging & Conflicts Production Scenario [L2]
🎯 Target Role / Context: Git Scenario #3 (L2) · Branching, Merging & Conflicts

Q: You ran `git merge` and Git stopped with conflicts in three files. Walk me through exactly how you resolve them, and explain what the conflict markers mean.

Resolve git merge conflicts systematically by identifying modified files with git status, inspecting diff3 conflict markers, editing to clean code, and finalizing with git commit.

#Git #L2 #Version Control #Collaboration #Branching
🎙️ Candidate Opening & Architectural Context
"When resolving <strong>git merge conflicts</strong> across multiple files, senior engineers follow a disciplined runbook: inspect modified files with git status, analyze conflict markers using the 3-way merge ancestor, test changes locally, and finalize the merge. Interviewers test whether you understand Git internals—such as common ancestors, diff3 markers, and git rerere—or whether you treat merge conflicts as guesswork."
Advertisement
⚡ Recommended Practice Lab

Want to master this scenario in a live sandbox? KodeKloud's Advanced Git Workflows, Rebase & Interactive Diagnostics covers this exact problem with hands-on terminal drills.

🛠️ Production Runbook & Step-by-Step Resolution

Direct Answer: When resolving <strong>git merge conflicts</strong> across multiple files, senior engineers follow a disciplined runbook: inspect modified files with git status, analyze conflict markers using the 3-way merge ancestor, test changes locally, and finalize the merge. Interviewers test whether you understand Git internals—such as common ancestors, diff3 markers, and git rerere—or whether you treat merge conflicts as guesswork.

1️⃣

Identify Conflicted Files to Resolve Git Merge Conflicts

Run git status to catalog every file marked 'both modified' before editing any code.

git status --short
# Conflicted files show 'UU' status (Unmerged, both modified):
# UU src/api/router.go
# UU config/production.yaml
# UU helm/values.yaml
  • Examine merge status: Run git status to distinguish clean auto-merges from files flagged as both modified.
  • Inspect current branch vs incoming branch: Verify your target branch with git branch --show-current and inspect the incoming commit with git rev-parse MERGE_HEAD.
  • Safety abort: If the conflict state was entered accidentally or in an uncommitted working tree, abort cleanly back to HEAD with git merge --abort.
2️⃣

Understand Git Conflict Markers & Enable diff3 Mode

Decode the standard conflict markers and activate diff3 or zdiff3 to reveal the common base ancestor commit.

⚡ Git Conflict Marker Tokens & Diff3 Inspection
Marker TokenOrigin / MeaningAction Required
col1col2col3
col1col2col3
col1col2col3
col1col2col3
  • <<<<<<< HEAD: Marks lines currently present on your checked-out branch (ours).
  • ||||||| base: Present when merge.conflictstyle=diff3 (or zdiff3) is configured. Displays the original code from the common ancestor commit before divergence.
  • =======: The horizontal divider separating your local branch changes from the incoming branch changes.
  • >>>>>>> feature-branch: Marks lines coming from the branch being merged into your current branch (theirs).
Advertisement
3️⃣

Resolve Hunks, Remove Markers & Execute Test Suites

Edit each conflicted file, combine valid business logic, remove all marker tokens, and execute local unit tests.

# Verify no remaining conflict markers in codebase
grep -rnE '^(<<<<<<<|=======|>>>>>>>)' .

# Run language unit tests to verify merged logic
go test -v ./...
  • Synthesize logic: Read both changes in context. Never blindly accept --ours or --theirs without validating business intent.
  • Verify zero leftover markers: Search working tree with grep -rnE '(<<<|>>>|===)' src/ to ensure no syntax errors slip through.
  • Run test suite: Execute local linting and unit test suites before staging.
4️⃣

Stage Resolved Files & Finalize the Merge Commit

Mark conflicts resolved using git add and finalize the merge commit.

git add src/api/router.go config/production.yaml helm/values.yaml
git diff --staged
git commit -m "Merge feature/auth-v2 into main: resolve router and config conflicts"
  • Stage resolved files: Run git add <file> to move resolved files from unmerged stage 1/2/3 to the index stage 0.
  • Inspect staged diff: Run git diff --staged to review the clean consolidated merge patch.
  • Commit: Conclude with git commit (Git automatically populates the default merge message referencing the merged branch).
5️⃣

Production Safeguards: git rerere & Trunk-Based Practices

Automate repetitive conflict resolution with git rerere and prevent drift with short-lived branches.

# Enable Reuse Recorded Resolution globally
git config --global rerere.enabled true
git config --global rerere.autoupdate true
  • Enable git rerere: Run git config --global rerere.enabled true so Git records resolved conflict hunks and automatically reapplies them when rebasing long-lived branches.
  • Short-lived feature branches: Enforce pull requests merged within 24-48 hours to minimize merge blast radius.
  • Automated merge conflict CI checks: Configure GitHub Actions / GitLab CI to run mergeability dry-runs on every pull request update.
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: Always configure 'git config --global merge.conflictstyle zdiff3'. Viewing the common base ancestor turns conflict resolution from blind guesswork between two divergent commits into a clear three-way diff where the intent of both engineers is immediately visible."
⚡ 60-Second Elevator Pitch Talking Points
  • I first run git status to inventory all files in 'both modified' state, confirming whether git merge --abort is needed or safe to proceed.
  • Using diff3 conflict markers (ours, common ancestor base, and theirs), I edit each file to integrate valid logic and strip all marker tokens.
  • I run unit tests locally, stage with git add, finalize the commit, and ensure git rerere is enabled globally to prevent re-resolving identical conflicts.
⛔ Critical Candidate Mistakes to Avoid in This Scenario

Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:

  1. Running raw git push --force rather than git push --force-with-lease on shared team feature branches git push --force unconditionally overwrites remote commits made by teammates, whereas --force-with-lease aborts if the remote ref was updated.
  2. Resolving complex merge conflicts with blind checkout overwrite strategies without running unit tests Unilateral conflict resolution frequently clobbers complementary logic introduced in parallel feature branches, creating regression bugs.
  3. Discarding corrupted working directories prematurely instead of recovering lost state using git reflog git reflog tracks every HEAD movement, allowing instant recovery of discarded commits, botched rebases, or deleted local branches.
  4. Disabling branch protection rules and mandatory PR approval reviews on shared release branches in git-q003-you-ran-git-merge-and-git-stopped-w Without branch protection, developers can bypass CI validation gates and push untested code directly to production branches.
Advertisement
Want more Git & Branching Workflows scenarios?
Explore our complete collection of scenario-based Git & Branching Workflows interview runbooks.
Browse All Git & Branching Workflows Questions →