I have two branches A and B. What I want to do is to create a new (merge) commit on A with the current state of A as parent that refers to the file tree described by B discarding anything from A. Basically the history of B should be squashed into a single commit.
The concrete repository state consists of two independend branches, that do not have a common ancestor (coming from two formererly independent repositories), but that describe the same content.
Now I want to find a "git"-way to bring them together. A basic solution (without git) would be to
checkout A and just copy the content of B into the working tree and do a git commit
. That is basically what I've done earlier to propagate the content of the second repository into the first one.
To do it with git I've tried
git checkout A
git merge --squash B
But unforunately it generated merge conflicts for all files that differ between A and B, what is definately not what I expected.
Basically something like
git merge --squash -s theirs
should do the job, but the merge strategy theirs
does not exist. Reading the docu shows
the possibility of using something like
git merge -X theirs
which is an option to the merge strategy recursive
. But this still does a merge of non-conflicting chunks. Only the conflicting chunks are taken directly from theirs
.