Skip to content

Instantly share code, notes, and snippets.

@kzelda
Last active January 13, 2021 09:25
Show Gist options
  • Save kzelda/4c6427a173c3d0ba03ee5a689ca2e06b to your computer and use it in GitHub Desktop.
Save kzelda/4c6427a173c3d0ba03ee5a689ca2e06b to your computer and use it in GitHub Desktop.
Rename git branch master to main
# Switch to the "master" branch:
$ git checkout master

# Rename it to "main":
$ git branch -m master main

# Get the latest commits (and branches!) from the remote:
$ git fetch

# Remove the existing tracking connection with "origin/master":
$ git branch --unset-upstream

# Create a new tracking connection with the new "origin/main" branch:
$ git branch -u origin/main

Source

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