Created
June 15, 2020 09:52
-
-
Save leth/8984b74267bdc82dd959930794091f2f to your computer and use it in GitHub Desktop.
Create new git repos with a 'main' branch rather than 'master'
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
# Add this to your .bash_profile | |
function git_init_fnc () { | |
\git "$@" | |
if [[ $1 == "init" ]];then | |
if [[ -n "$2" ]]; then | |
git_dir="$2"; | |
else | |
git_dir=`pwd`; | |
fi | |
default_branch="main" | |
( | |
cd $git_dir | |
\git symbolic-ref HEAD refs/heads/$default_branch | |
) | |
fi | |
} | |
alias "git"=git_init_fnc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment