Resolving Merge Conflicts
A conflict occurs when Git cannot automatically reconcile changes, often because different branches modified overlapping lines. Git marks conflicted files with conflict markers such as <<<<<<<, =======, and >>>>>>>.
The resolution process is: inspect conflicts → edit the file into the desired final state → stage the resolved file → continue the merge or rebase.
Resolve a Merge Conflict
git status
# edit conflicted files
git add src/app.js
git commit
# During a rebase:
git add src/app.js
git rebase --continue💡 After resolving the file contents, staging marks the conflict as resolved. During a merge, the next step is normally committing; during a rebase, use
git rebase --continue.Key Takeaways
- Conflict markers must be removed from the final file.
- Git considers a conflict resolved when the corrected file is staged.
git rebase --abortcan safely cancel an in-progress rebase.
Knowledge Check
What should you normally do after manually resolving a conflicted file?