How to resolve merge conflicts in Git
Fix conflicting changes when merging or rebasing.
git statusFiles with conflicts are listed under "both modified". Look for conflict markers (<<<<<<<) in those files.
# In the file, you'll see:
<<<<<<< HEAD
your changes
=======
their changes
>>>>>>> feature-branchRemove the conflict markers and keep the correct code (yours, theirs, or a combination).
Most editors (VS Code, IntelliJ) have merge conflict UI — look for "Accept Current", "Accept Incoming" buttons.
git add filename.txtAfter fixing conflicts in a file, stage it to mark it as resolved.
git commitCreates the merge commit. Git pre-fills the message with merge details.
git checkout --ours filename.txtKeeps your version of the file and discards incoming changes.
When to use: When you know your version is definitively correct for a specific file.
git checkout --theirs filename.txtKeeps the incoming version and discards your changes.
When to use: When the incoming version is definitively correct for a specific file.