Skip to content

Instantly share code, notes, and snippets.

@aliwatters
Last active January 20, 2021 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aliwatters/472d1a6d12dbfd10dfc7ffd844595db7 to your computer and use it in GitHub Desktop.
Save aliwatters/472d1a6d12dbfd10dfc7ffd844595db7 to your computer and use it in GitHub Desktop.
Default to main branch on git init
#!/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