Skip to content

Instantly share code, notes, and snippets.

@mikemichaelis
Created September 30, 2016 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikemichaelis/91f4e7cee5f3cd40b88fbf1fa5417146 to your computer and use it in GitHub Desktop.
Save mikemichaelis/91f4e7cee5f3cd40b88fbf1fa5417146 to your computer and use it in GitHub Desktop.
http://stackoverflow.com/questions/2763006/change-the-current-branch-to-master-in-git
The problem with the other two answers is that the new master doesn't have the old master as an ancestor, so when you push it, everyone else will get messed up. This is what you want to do:
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment