Last active
June 18, 2020 07:19
-
-
Save cweinberger/31e344d3388fea0f03de2a961e010c52 to your computer and use it in GitHub Desktop.
Change branch from `master` to `main`
This file contains hidden or 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
# if you are using GitHub, you can use this tool to change all repos at once | |
# https://github.com/mheap/github-default-branch | |
# Rename dev to develop | |
github-default-branch --pat <token> --repo user/repo --old dev --new develop | |
# Rename all repos owned by an org | |
github-default-branch --pat <token> --org my-org-name | |
# Rename all repos owned by a user | |
github-default-branch --pat <token> --user my-user-name |
This file contains hidden or 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
# create a template file for git | |
# replace `main` with your new default branch name | |
echo "ref: refs/heads/main" > ~/.config/git/template/HEAD | |
# update your git config | |
# Note: if you already have specified an [init] section, open ~/.gitconfig and add this yourself: | |
# ~~~ | |
# [init] | |
# templateDir = ~/.config/git/template" | |
# ~~~ | |
echo "[init]\n\ttemplateDir = ~/.config/git/template" >> ~/.gitconfig | |
# test `git init` | |
# should create a main branch and output: "Reinitialized existing Git repository in {path}/.git/" | |
git init |
This file contains hidden or 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
# rename `master` branch to `main` | |
git branch -m master main | |
# push to origin | |
git push origin -u main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment