I have a repo with diverging master and Feature branch,like this:
master: A -- B -- C -- etc.
\
Feature: \-H -- I -- J
I now realize that all the commits in the master branch after B should be discarded and Feature should become the new master. So, I would like to take all the commits in the Feature branch from H on and rebase them on top of master, discarding everything that happened in master after B. In short, I would like this:
master: A -- B -- C -- XX K -- etc.
\ /
Feature: \-H -- I -- J /
There is an old answer (2016) that suggests this option:
git rebase -s recursive -X theirs master
The command is presumably applied (I may be wrong; there are not a lot of details in the answer) after Feature has been checked out.
So, questions:
master to old_master and moving Feature to master, but it seems recent versions of Git impose constraints on renaming the master branch, as do GitHub and BitBucket (which is where the remotes of my repo are).BTW, this is a private repo with no other users, although it is regularly checked out from different machines.
You can:
git checkout master
git branch master_old
git checkout master_old
git push -u origin master_old
Only if you want the old master to exist
git checkout master
git reset --hard Feature
git push --force origin master