GIT force take branch changes

Situation:

[origin/branch1]  [branch1]    took only partial changes from branch2 during merge
[origin/branch2]  [branch2]    has changes 1, 2, 3


In other words, branch1 has only done a partial merge of branch2. As such branch2 has changes that are 'newer' than branch1. You can complete the merge with the following commands.

git checkout branch1
git merge branch2

But this isn't what you want. You left out those merges on purpose. In this case, you know that branch1 is up-to-date (even though it has left out some files from branch2). What you really want to do is to overwrite branch2 with branch1. You can do this with the following commands.

git checkout branch1 # branch missing files
git merge -s ours branch2 # branch with unnecessary changes


No comments: