Why does git checkout --ours/theirs not work?

105 Views Asked by At

I want to update my template from the source, so I use these commands:

git remote add template https://github.com/ObsidianPublisher/template-netlify-vercel
git pull template main --allow-unrelated-histories

Then I list all the conflict files:

git diff --name-only --diff-filter=U
A
B
C

So far so good. I want to keep A. The rest should be overwritten. I use:

git checkout --ours -- A
git checkout --theirs -- .

But checking it again it doesn't work:

git diff --name-only --diff-filter=U
A
B
C

Why is that?

1

There are 1 best solutions below

7
j6t On BEST ANSWER

git checkout --ours and git checkout --theirs only change the file in the working tree, but do not resolve the conflict. You still have to git add the so checked out file to mark the conflict resolved.