Skip to content

Instantly share code, notes, and snippets.

@haroldcris
Last active September 23, 2020 13:19
Show Gist options
  • Select an option

  • Save haroldcris/07ae5b2d882d8f9511a985365cb8e26f to your computer and use it in GitHub Desktop.

Select an option

Save haroldcris/07ae5b2d882d8f9511a985365cb8e26f to your computer and use it in GitHub Desktop.
Replace Master Branch with other Branch
// 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