Last active
July 10, 2020 16:07
-
-
Save arichar6/357c0254c7d84603ce7256f2a74f8a22 to your computer and use it in GitHub Desktop.
These commands should let you rename the default branch in a git repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# On your local clone, make sure that your code is up to date with the remote (called `origin`) | |
git pull origin master | |
# Then rename your local `master` branch to `main` | |
git branch -m master main | |
# Then push your `main` branch back to `origin`, using a command that will make a new branch called `main` on the remote. | |
git push origin HEAD | |
# After this, you can: | |
# - Edit any existing pull requests to point to `main` instead of `master` | |
# - Change the "default" branch to be `main` (this applies to GitHub and GitLab remotes) | |
# - Delete the `master` branch if desired (or leave it, in case you run into problems) | |
# You can also repeat the above commands for other remotes, if applicable. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment