Git: fatal: '--ours / - theirs' cannot be used with switch branches

In a merge conflict, I try to resolve all merge conflicts in favor of a particular branch.

I try to do git checkout --ours , but I get the following error:

 fatal: '--ours/--theirs' cannot be used with switching branches 

How can I achieve what I am trying to do?

+17
source share
2 answers

Using git checkout with --ours or --theirs expects at least one argument: file / directory path to check.

As the manual says:

When checking paths from the index, check step # 2 (ours) or # 3 (them) for unbound paths.

So:

 git checkout --ours <path(s)> 
+14
source

Well, you can use cherry-pick to clone everything from the branch marked with --theirs to your current HEAD .

 git cherry-pick <commit you want to copy> 
0
source

Source: https://habr.com/ru/post/1012783/


All Articles