分支默認(rèn)為
main
余寥,從git 2.28
版本開始支持,確保本地git
版本大于等于2.28
悯森。
一劈狐、查看或升級本地git
版本
1、通過brew
安裝的git
呐馆,或升級git
$ brew install git
$ brew upgrade git
Warning: git 2.29.2 already installed
2肥缔、查看git
版本
發(fā)現(xiàn)與brew
安裝的Git
沒有關(guān)聯(lián),關(guān)聯(lián)的是Mac
默認(rèn)的Git
$ git --version
git version 2.23.0
3汹来、將git
關(guān)聯(lián)到brew
安裝的Git
上
$ brew link git --overwrite
Linking /usr/local/Cellar/git/2.29.2... 209 symlinks created
4续膳、再次查看本地git
版本
$ git --version
git version 2.29.2
二、配置
1收班、查看本地的默認(rèn)分支配置
$ cat /Users/yuanzhiying/.gitconfig
$ cat /Users/yuanzhiying/.gitconfig
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[user]
name = yuanzhiying
email = *********@qq.com
2坟岔、設(shè)置main
為git init
默認(rèn)分支
$ git config --global init.defaultBranch main
3、再次查看本地配置
$ cat /Users/yuanzhiying/.gitconfig
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[user]
name = yuanzhiying
email = ********@qq.com
[init]
defaultBranch = main
4摔桦、驗(yàn)證
# yuanzhiying @ yingiMac in ~/test [12:18:54]
$ git init
已初始化空的 Git 倉庫于 /Users/yuanzhiying/test/.git/
# yuanzhiying @ yingiMac in ~/test on git:main x [12:18:57]