Skip to content

Instantly share code, notes, and snippets.

@primaryobjects
Last active December 23, 2020 20:55
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 primaryobjects/625fee86ee3e71978eeb96694a9d6d6b to your computer and use it in GitHub Desktop.
Save primaryobjects/625fee86ee3e71978eeb96694a9d6d6b to your computer and use it in GitHub Desktop.
How to Rename Your "master" Branch to "main" on GitHub

How to Rename Your "master" Branch to "main" on GitHub

The following steps may be used to rename your "master" branch to "main" on GitHub.

Use the following commands from a command-prompt.

  1. git checkout master
  2. git branch -m main
  3. git push origin -u main
  4. Navigate to your project's repository on GitHub.
  5. Click the Settings tab along the top.
  6. Click Branches in the left menu.
  7. Change the dropdown from master to main and click Update.
  8. git push origin --delete master

Note, be sure to check any hyperlinks or screenshot urls in your repo that might be pointing to files on the old branch name and update the urls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment