Notes

Replace and overwrite branches in Git

Edit on GitHub

Git & Github

tl;dr

1# merge a branch on top of your existing master
2git checkout hotstuff
3git merge -s ours master
4git checkout master
5git merge hotstuff

NOTES:

  • -s ours or --strategy=ours will get rid of all changes in the other (obsolete) branch and overwrite with our branch (the branch you’er currently in).
  • If you are using our with a master branch, it’ll overwrite everything in master and prefer changes in the other branch
  • You can use --no-commit when merging to avoid the need of a commit message

You can also try obliterating master all together:

1git push -f origin hotstuff:master

This is useful when the other branch is not based off of master and the branch histories are completely irrelevant