Last active
January 20, 2021 03:58
-
-
Save aliwatters/472d1a6d12dbfd10dfc7ffd844595db7 to your computer and use it in GitHub Desktop.
Default to main branch on git init
This file contains 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
#!/bin/bash -x | |
# from git 2.28 | |
git config --global init.defaultBranch main | |
# before git 2.28 | |
# set git to use "main" instead of "master" on `git init` | |
# suggestion - run commands these manually! | |
# show existing settings | |
git config --global --list | |
# add in a new template | |
mkdir -p .git-template | |
echo "ref: refs/heads/main" > ~/.git-template/HEAD | |
git config --global init.templateDir ~/.git-template | |
# show new settingss | |
git config --global --list | |
# test | |
mkdir test_project && cd test_project && git init && git status | |
cd .. && rm -r test_project |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment