Conflicts & Merge

How to Resolve Git Merge Conflicts Accepting Ours or Theirs

Quickly resolve merge conflicts across files by accepting all changes from your branch (--ours) or the incoming branch (--theirs).

Instant 1-Line Solution
Reversible (History Change)Intermediate
git checkout --ours <file> OR git checkout --theirs <file>
When to use this scenario:A generated file (like package-lock.json or schema.rb) has 100 conflict lines and you want to completely accept one version.

Step-by-Step Execution Guide

1Accept your current branch version (Ours)
git checkout --ours <file-path>

Replaces the conflicted file with the version from the branch you are currently on.

2Accept incoming branch version (Theirs)
git checkout --theirs <file-path>

Replaces the conflicted file with the incoming version from the branch being merged.

3Stage the resolved file and commit
git add <file-path> && git commit -m "fix: resolve conflict using theirs"

Marks the conflict as resolved and finalizes the merge.

Critical Pitfalls & Precautions

  • β€’During a "git rebase", the meanings of "ours" and "theirs" are swapped because rebase replays your commits onto upstream.
Frequently Asked Questions

Accept Ours / Theirs in Merge - Frequently Asked Questions

Common questions about safe rollback, remote history implications, and troubleshooting.

Run "git checkout --theirs ." followed by "git add ." to accept incoming changes across the entire workspace.