Last active
September 23, 2020 13:19
-
-
Save haroldcris/07ae5b2d882d8f9511a985365cb8e26f to your computer and use it in GitHub Desktop.
Replace Master Branch with other Branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // taken from https://stackoverflow.com/questions/2862590/how-to-replace-master-branch-in-git-entirely-from-another-branch | |
| Replace master with seotweaks branch | |
| git checkout seotweaks | |
| git merge -s ours master | |
| git checkout master | |
| git merge seotweaks | |
| The result should be your master is now essentially seotweaks. | |
| (-s ours is short for --strategy=ours) | |
| From the docs about the 'ours' strategy: | |
| 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. | |
| Update from comments: If you get fatal: refusing to merge unrelated histories, then change the second line to this: git merge --allow-unrelated-histories -s ours master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment