Skip to content

Instantly share code, notes, and snippets.

@erictleung
Created July 26, 2021 05:31
Show Gist options
  • Save erictleung/43fea268292dce118f32cf0ad2e1292c to your computer and use it in GitHub Desktop.
Save erictleung/43fea268292dce118f32cf0ad2e1292c to your computer and use it in GitHub Desktop.
Update local git repository from master to main branch on upstream
# Sources:
# - https://www.git-tower.com/learn/git/faq/git-rename-master-to-main/
# - https://gist.github.com/kelynch/9ba595e369c304b560477f3636b41e8a
git checkout master # Assumes master is default branch
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment