Resolve conflicts automatically with git-mergetool
Asked Answered
A

1

1

Now i resolve few conflicts, and want retain only remote state.

If i try change my option: git merge --strategy-option theirs
I have getting, error: 'merge' is not possible because you have unmerged files.

Of course, i can cancel my changes (for use command above), but then i will lose my changes.

Now, me offering run vimdiff: {local}: modified file {remote}: modified file Hit return to start merge resolution tool (vimdiff):

How i can retain only remote state. If file not exist - it easy (offer push the button).

Thanks.

Afforest answered 28/2, 2015 at 13:25 Comment(0)
D
2

Use the git checkout command to set the working tree to match the remote stage (3):

git checkout -3 PATHS...

Or the local stage (2):

git checkout -2 PATHS...

Then add the files and commit to complete the merge.

Use git checkout -h if you forget which one is 2 and 3.

Darcie answered 28/2, 2015 at 14:29 Comment(5)
Perhaps you don't understand me. I don't want change my branch with remote stage. Now i have status 20 files changed and 30 files need to be merged, i don't want do merge by hand via mergetool, i want say to "git mergetool" what he must use only remote files.Afforest
I want use, something like: Hit return to start merge resolution tool (vimdiff): remote. But this not working, this it run vimdiff.Afforest
The git checkout command is has two very distinct functionality. When you specify a branch, it changes current HEAD (and stage and working tree) to that branch. But when you specify a path, it copies all files from another place to the working directory, without changing the current branch. The -2 or -3 options specifies that you want to copy the files from the local or remote sides of merge, respectively. It is not the same as changing the branch to the remote one.Verditer
I try use "git checkout -3" without PATHS (i don't understand what is it, it name of branch?). But get message "fatal: '--ours/--theirs' cannot be used with switching branches".Afforest
Paths are the file or directory names. If you use git checkout without any files, then it takes the meaning of switching branches, which is not what you want. See git checkout --help for details.Verditer

© 2022 - 2024 — McMap. All rights reserved.