环境信息
Git 版本信息:
$ git--versiongit version 2.33.0.windows.1
设置全局用户名和邮箱
设置全局用户名:
$ git config --global user.name "hello"
设置全局邮箱:
$ git config --global user.email "[email protected]"
查看配置
列出配置文件中所有变量及其值,第 16 ~ 17 行是刚刚设置的全局用户名和邮箱:
$ git config --listdiff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
pull.rebase=false
credential.helper=manager-core
credential.https://dev.azure.com.usehttppath=true
init.defaultbranch=master
user.name=hello
[email protected]
配置文件 .gitconfig 位于用户目录(~)中:
$ ls-la ~
total 67
drwxr-xr-x 1 Admin 1971210 Apr 1110:20 ./
drwxr-xr-x 1 Admin 1971210 Jul 192021../
-rw-r--r-- 1 Admin 1971213356 Mar 2218:45 .bash_history
-rw-r--r-- 1 Admin 19712149 Apr 1110:20 .gitconfig
-rw-r--r-- 1 Admin 19712120 Apr 1110:20 .lesshst
-rw-r--r-- 1 Admin 19712116 Jul 142023 .npmrc
-rw-r--r-- 1 Admin 19712118367 Sep 162021 .viminfo
-rw-r--r-- 1 Admin 197121944 Apr 215:20 allegro.jrl
-rw-r--r-- 1 Admin 197121948 Mar 1413:42 allegro.jrl,1
drwxr-xr-x 1 Admin 1971210 Jul 192021 cdssetup/
-rw-r--r-- 1 Admin 1971218465 Jul 192021 license_use.log
-rw-r--r-- 1 Admin 197121609 Aug 112021 pad_designer.jrl
-rw-r--r-- 1 Admin 197121624 Jul 222021 pad_designer.jrl,1
drwxr-xr-x 1 Admin 1971210 Apr 711:39 pcbenv/
使用
cat ~/.gitconfig
命令可以查看位于用户目录中的配置文件:
$ cat ~/.gitconfig
[user]
name = hello
email [email protected]
参考
如何配置 Git 用户名和邮件地址
git-config(1) Manual Page
版权归原作者 好好活着,不要熬夜 所有, 如有侵权,请联系我们删除。