1

I have two branches: cat and dog. Their histories have diverged.

I would like to merge dog into cat. In this merge, how can I accept the dog version of all files automatically, instead of having to resolve the merge with git add/rm and repeating the commit?

Likewise, how can I accept the cat version of all the files?

1

1 Answer 1

4

To accept all dog versions when merging dog into cat:

$ git checkout cat $ git merge -s recursive -X theirs dog 

To accept all cat versions when merging dog into cat:

$ git checkout cat $ git merge -s recursive -X ours dog 

-X specifies an option for the strategy specified by -s. Git merges proceed relative to the currently checked out branch, so theirs and ours are relative to the currently checked out branch.

The recursive strategy is often the default, so you might not have to use -s.

Documented at git-merge(1).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.