Interview Q&A / Git & GitHub

IntermediateQuick answer1 min readUpdated 3 Oct 2026

What do --ours and --theirs mean when resolving a conflict?

SHORT ANSWER

In a merge, ours is the branch you are on and theirs is the branch being merged in. git checkout --ours file or --theirs file takes that whole version of the file. In a rebase the meaning is reversed.

Explain it simply

When settling a dispute you sometimes decide 'just take my version for this file'. The flags do that for a whole file.

During git merge feature on main, ours is main and theirs is feature. During git rebase main on feature, Git is replaying your commits onto main's history, so 'ours' is main (the base being built) and 'theirs' is your own commit. Because it surprises everyone, check with git diff after choosing. For a mix, edit the file by hand. The merge strategy option -X ours is different: it resolves only the conflicting hunks in your favour.

Example

bash
git checkout --theirs pricing.json   # take incoming version
git add pricing.json
git merge -X ours feature            # prefer my side on conflicts

What to say in the interview

"In a merge, ours is the current branch and theirs the incoming one. In a rebase it is swapped. I can take a whole file with checkout --ours or --theirs, but I review the result, and I know -X ours only decides conflicting hunks."

#git#conflicts#ours-theirs

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.