Reputation: 4453
I have two branches A and B and I want to merge B into A. However, I don't want any changes from B to transfer to A. A should remain unchanged except for manual changes done after the merge. I know that this technically goes against the whole idea of merging, but this is about documenting that these branches are related. What I do want, is that the graph of the repository shows a merge between these two graphs at the corresponding commit i.e. I want git to "think" that there was an actual merge.
One possible approach would be to do a reset
after the merge. However, this does not in a graph as described above. There is no actual link between the branches.
Upvotes: 5
Views: 686
Reputation: 94483
This is called "null merge". Use --strategy=ours
:
git checkout A
git merge -s ours B
PS. Don't confuse --strategy=ours
and
--strategy-option=ours
; the latter is an option for default recursive strategy; the option merges files that don't have conflicts.
Upvotes: 11
Reputation: 562
If you take the diff
of Branch B->A, and the diff
of A->B, you can merge B->A, then commit the diff
A->B, essentially undoing any changes. You will have an extra commit and the changes will be tracked though.
Upvotes: 1