1

I have two branches, A and B. Those have deviated quite a bit over time, and trying to merge A and B results in a ton of conflicts. I don't actually need many things from B, and those things need to be in different places now.

So I'd like to make B look exactly like A - not a merge, no extra files, no file changes, literally like I'd just called git checkout -b B while in A.

However, I don't want to lose B's history. What I want is for git to create a differential commit that shows what needed to change in B to make it look exactly like A.

Is there such a command?

Michael Stum
  • 177,530
  • 117
  • 400
  • 535
  • This question is slightly different than the one that is marked as a duplicate - in that question the author is willing to discard the history, and so git-reset is a valid option. Here, history needs to be preserved. The answer is `git symbolic-ref HEAD refs/heads/` from branch A and then a simple Add and Commit. If this question removes the duplicate marking then I can post this as answer and elaborate a bit more. – eedrah Apr 16 '18 at 20:58
  • Looks like the other question wants to do a partial merge too, further to my point. – eedrah Apr 16 '18 at 21:00

1 Answers1

0

When you do a merge you don't lose the history provided you didn't do any fast forward. You could just branch from b, merge a into it

Eric Yang
  • 2,678
  • 1
  • 12
  • 18
  • The OP is asking something different - how do they do a merge so that `B` looks *exactly* like `A`? – Oliver Charlesworth Apr 16 '18 at 19:20
  • Indeed. `git merge A` while in B results in a ton of merge conflicts that aren't worth resolving since it's mostly cheese moving. So I want to make B look exactly like A, and then just manually reapply the actual changes, but I need to keep B's history. (Otherwise I'd just delete B and branch off of A again). Looking at [this approach](https://stackoverflow.com/a/47704784/91) right now. – Michael Stum Apr 16 '18 at 19:22