How to replace git branch with another (and still maintain history)

git checkout new-branch
git merge -s ours old-branch
git checkout old-branch
git merge new-branch

Line 2 says that any changes to old-branch will be replaced with updates in new-branch.

It may seem odd that we switched to new-branch to prepare old-branch, but this establishes the priority for when we ultimately merge old-branch in step 4.

This resolves any number of heads, but the resulting tree of the merge is always that of the current branch head, effectively ignoring all changes from all other branches. It is meant to be used to supersede old development history of side branches. Note that this is different from the -Xours option to the recursive merge strategy.

https://stackoverflow.com/questions/2862590/how-to-replace-master-branch-in-git-entirely-from-another-branch