Skip to content

Instantly share code, notes, and snippets.

@tbennett
Created September 10, 2022 10:29
Show Gist options
  • Save tbennett/acb595ea0f84431162924f0959507d53 to your computer and use it in GitHub Desktop.
Save tbennett/acb595ea0f84431162924f0959507d53 to your computer and use it in GitHub Desktop.
Reconfig git and GitHub master to main
# Setting Up to Use Git
Github > Settings > Branches > Default branch --> change to main
For your local Git install, there is a config option called init.DefaultBranch. Just set it and forget it.
__git config --global init.defaultBranch main__
You're good going forward!
_______
## If you want to change an existing repo:
1. git branch -m master main
2. git push -u origin main
3. git push origin --delete master
---------
1. Go to the master branch
2. Rename master to main locally
3. Get the latest commits from the server
4. Remove the link to origin/master
5. Add a link to origin/main
6. Update the default branch to be origin/main
________
[renaming master branch to main](https://www.hanselman.com/blog/easily-rename-your-git-default-branch-from-master-to-main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment