Resolve Git merge conflict using all my changes, discarding theirs

While merging branch A into branch B, Git reported several conflicts. I want to resolve the conflicts by keeping branch A's version of each file. I don't care about the content in branch B.

Is there a command I can use to resolve all the merge conflicts by keeping my version of the file (the version within branch A)?

Answers


In fact, using Git's terminology you want to discard "ours" and keep "theirs". This is because you are on branch B when you do the merge, which makes that "ours".

git checkout B
git merge -s recursive -X theirs A

From the documentation:

The recursive strategy can take the following options:

ours
    This option forces conflicting hunks to be auto-resolved
    cleanly by favoring our version. Changes from the other tree
    that do not conflict with our side are reflected to the merge
    result. For a binary file, the entire contents are taken from
    our side.

    This should not be confused with the ours merge strategy, which
    does not even look at what the other tree contains at all. It
    discards everything the other tree did, declaring our history
    contains all that happened in it.

theirs
    This is the opposite of ours.

Need Your Help

Printing verbose progress from sed and awk

sed awk

The programs sed and awk usually does their work quietly. Is there any way to get these programs to state what they are doing?

C++: OpenMP shared memory protection

c++ multithreading parallel-processing openmp shared-memory

If I use a shared variable, let's say a double, to calculate some kind of sum along the execution of the program. Would that in anyway be vulnerable to non-stable operations? I mean, would it be po...