git config 配置修改

Git 配置文件

  Git 自带一个 git config 的工具来帮助设置控制 Git 外观和行为的配置变量。 这些变量存储在三个不同的位置:

  • /etc/gitconfig 文件: 包含系统上每一个用户及他们仓库的通用配置。 如果使用带有 --system 选项的 git config 时,它会从此文件读写配置变量。
  • ~/.gitconfig~/.config/git/config 文件:只针对当前用户。 可以传递 --global 选项让 Git 读写此文件。
  • 当前使用仓库的 Git 目录中的 config 文件(就是 .git/config):针对该仓库。

  每一个级别覆盖上一级别的配置,所以 .git/config 的配置变量会覆盖 /etc/gitconfig 中的配置变量。


用户信息

  当安装完 Git 应该做的第一件事就是设置你的用户名称与邮件地址。 这样做很重要,因为每一个 Git 的提交都会使用这些信息,并且它会写入到你的每一次提交中,不可更改:

配置用户名
$ git config --global user.name "loushengyue"
查看已配置的用户名
$ git config --global user.name
loushengyue
配置邮箱
$ git config --global user.email [email protected]
查看已配置的邮箱
$ git config --global user.email
[email protected]

如何查看".gitconfig"文件

  在"Git Bash"命令行工具中输入“cd && ls -a”便可以看到如下信息:

$ cd && ls -a
 ./
 ../
 .android/
 .bash_history
 .config/
 .eclipse/
 .gem/
 .gitbook/
 .gitconfig
  ……

  再通过“view .gitconfig”命令打开.gitconfig文件,即可查看该配置文件内容:

[user]
		name = loushengyue
		email = [email protected]
[filter "lfs"]
		smudge = git-lfs smudge -- %f
		process = git-lfs filter-process
		required = true
		clean = git-lfs clean -- %f

检查配置信息

  通过“git config --list”命令也可以查看git的配置信息,例如:

$ git config --list
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.required=true
filter.lfs.process=git-lfs filter-process
credential.helper=manager
user.name=loushengyue
user.email=[email protected]
……


欢迎点赞,谢谢关注:)

猜你喜欢

转载自blog.csdn.net/weixin_41424247/article/details/88358961