Skip to content

Instantly share code, notes, and snippets.

@julianhyde
Created October 29, 2021 18:38
Show Gist options
  • Save julianhyde/79a733e524d0d4f09f51dcbf78128821 to your computer and use it in GitHub Desktop.
Save julianhyde/79a733e524d0d4f09f51dcbf78128821 to your computer and use it in GitHub Desktop.
How to fix a GitHub clone after the remote 'master' branch has been renamed to 'main'
# (Instructions are based on the "What Your Teammates Have to Do" section
# in https://www.git-tower.com/learn/git/faq/git-rename-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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment