0
0
Gitdevops~10 mins

Resolving merge conflicts in Git - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Resolving merge conflicts
Start merge
Git detects conflict?
NoMerge completes
Yes
Show conflict markers in files
User edits files to resolve conflicts
User marks conflicts resolved (git add)
User completes merge (git commit)
Merge finished successfully
This flow shows how Git detects conflicts during a merge, how the user resolves them by editing files, and then completes the merge.
Execution Sample
Git
git merge feature-branch
# Conflict detected in file.txt
# Edit file.txt to fix conflicts
git add file.txt
git commit -m "Resolve merge conflict"
This sequence merges a branch, resolves conflicts in a file, stages the fix, and commits the merge.
Process Table
StepActionGit StateUser ActionResult
1Run 'git merge feature-branch'Merge started, conflict detected in file.txtNoneMerge paused, conflict markers added in file.txt
2Open file.txtConflict markers visibleEdit file.txt to choose correct codeConflicts resolved in file.txt content
3Run 'git add file.txt'Conflict marked as resolvedStage resolved filefile.txt ready for commit
4Run 'git commit -m "Resolve merge conflict"'Merge commit createdComplete merge with commitMerge finished successfully
💡 Merge completes after user resolves conflicts and commits
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
file.txtClean versionContains conflict markers <<<<<<< >>>>>>>Edited to resolved contentStaged resolved contentCommitted resolved content
Key Moments - 3 Insights
Why does Git add conflict markers in the file?
Git inserts conflict markers to show the conflicting parts from each branch, as seen in Step 1 and Step 2 of the execution_table.
What does 'git add' do after resolving conflicts?
'git add' tells Git the conflicts in the file are resolved and stages the file for commit, shown in Step 3.
Why must you commit after resolving conflicts?
Committing finalizes the merge and records the resolution, as shown in Step 4 where the merge finishes.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the Git state immediately after running 'git merge feature-branch'?
ANo conflicts detected
BMerge completed successfully
CMerge started, conflict detected in file.txt
Dfile.txt staged for commit
💡 Hint
Check Step 1 in the execution_table under 'Git State'
At which step does the user mark the conflict as resolved by staging the file?
AStep 2
BStep 3
CStep 1
DStep 4
💡 Hint
Look for 'git add file.txt' in the execution_table
If the user forgets to run 'git add' after editing the file, what will happen?
AGit will keep the merge paused, waiting for conflict resolution
BMerge will complete automatically
CGit will still commit the merge
DGit will delete the conflicting file
💡 Hint
Refer to the role of 'git add' in Step 3 of the execution_table
Concept Snapshot
git merge may detect conflicts if changes overlap
Git adds conflict markers in files to show conflicts
User edits files to resolve conflicts manually
Run 'git add <file>' to mark conflicts resolved
Run 'git commit' to complete the merge
Full Transcript
When you run 'git merge' and Git finds conflicting changes, it pauses the merge and adds conflict markers in the affected files. You open those files and edit them to fix the conflicts by choosing or combining changes. After editing, you run 'git add' on the files to tell Git the conflicts are resolved. Finally, you run 'git commit' to finish the merge and save the resolution. This process ensures you control how conflicting changes are combined.