I have a master branch and a migration branch. We completely changed the codebase in the migration branch, and now we want to replace the master branch with the migration branch. Is there a proper way to do this? I think merging is not an option, as I want to replace Master. Also, the master branch is a protected branch, so I can't directly force push in the master. I tried merging, but I am getting lots of conflicts, which I don't want to have as it is a replacement, not a merge. Is there any proper way to deal with this situation?
You could first merge master
into a branch started from migration
forcing git to not bring over any changes from master
(so keeping stuff as it is in migration
) and then create a PR into master
which then will leave the commit tree just like it is in migration
so you get the desired result:
git fetch origin
git checkout -b recipe origin/migration
git merge -s ours origin/master # we merge master _but_ we discard any changes coming from that branch
Now, you can create a PR using the branch and once you merge it into master
, the branch will have the content of migration
..... just make sure you do a real merge and not a rebase or squash merge... that is so that, in history, the 2 branches look related.