92
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
git merge --strategy=ours --no-commit master git commit # add information to the template merge message
86
git checkout main
git reset --hard better_branch
git push -f origin main
76
git checkout new-master git branch -m master old-master git branch -m new-master master # And don't do this part. Just don't. But if you want to... # git branch -d --force old-master
mv -i .git/refs/new-master .git/refs/master git checkout master
67
git branch -M branch_name master
52
git branch -f master HEAD
git push -f origin master
# This will force push the current branch to the remote master git push -f origin HEAD:master # Switch current branch to master git checkout master # Reset the local master branch to what's on the remote git reset --hard origin/master