Skip to content

Instantly share code, notes, and snippets.

@DevoKun
Last active June 28, 2022 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DevoKun/f9d1653d16a91226c15b96f5f561432c to your computer and use it in GitHub Desktop.
Save DevoKun/f9d1653d16a91226c15b96f5f561432c to your computer and use it in GitHub Desktop.
Change GitHub Master branch name to Main
git pull # Pull first or lose ANY commits upstream
git branch -m master main # Rename branch locally
echo
echo "Change GitHub default branch to 'main'."
echo
echo "Is GitHub Default Branch 'main'?"
echo
read -p "Press ENTER to continue"
echo
git push origin :master # Delete the old branch
git push --set-upstream origin main # Push the new branch, set local branch to track the new remote
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment