Skip to content

Instantly share code, notes, and snippets.

@c0mpiler
Created September 25, 2018 01:56
Show Gist options
  • Save c0mpiler/655c5fd45efe79f3d09f66513b38ab46 to your computer and use it in GitHub Desktop.
Save c0mpiler/655c5fd45efe79f3d09f66513b38ab46 to your computer and use it in GitHub Desktop.
(Because I always forget) How to overwrite a master branch with a remote branch
git checkout better_branch
git merge --strategy=ours master # keep the content of this branch, but record a merge
git checkout master
git merge better_branch # fast-forward master up to the merge
----------------------
If you want your history to be a little clearer, I'd recommend adding some information to the merge commit message to make it clear what you've done. Change the second line to:
git merge --strategy=ours --no-commit master
git commit # add information to the template merge message
----------------------
# From this SO answer: http://stackoverflow.com/questions/2763006/change-the-current-branch-to-master-in-git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment