外观
Git 更新配置命令
约 531 字大约 2 分钟
2024-06-27
git config
主要是用来配置 Git 的相关参数,其主要操作有:
查看配置信息
–local:仓库级,–global:全局级,–system:系统级
git config <--local | --global | --system> -l查看当前生效的配置信息
git config -l编辑配置文件
–local:仓库级,–global:全局级,–system:系统级
git config <--local | --global | --system> -e添加配置项
–local:仓库级,–global:全局级,–system:系统级
git config <--local | --global | --system> --add <name> <value>获取配置项
git config <--local | --global | --system> --get <name>删除配置项
git config <--local | --global | --system> --unset <name>配置提交记录中的用户信息
git config --global user.name <用户名>
git config --global user.email <邮箱地址>更改Git缓存区的大小
如果提交的内容较大,默认缓存较小,提交会失败
缓存大小单位:B,例如:524288000(500MB)
git config --global http.postBuffer <缓存大小>调用 git status/git diff 命令时以高亮或彩色方式显示改动状态
git config --global color.ui true配置可以缓存密码,默认缓存时间15分钟
git config --global credential.helper cache配置密码的缓存时间
缓存时间单位:秒
git config --global credential.helper 'cache --timeout=<缓存时间>'配置长期存储密码
git config --global credential.helper storeGit 一共有3个配置文件:
- 仓库级的配置文件:在仓库的
.git/.gitconfig,该配置文件只对所在的仓库有效。 - 全局配置文件:Mac 系统在
~/.gitconfig,Windows 系统在C:\Users\\.gitconfig。 - 系统级的配置文件:在 Git 的安装目录下(Mac 系统下安装目录在
/usr/local/git)的etc文件夹中的gitconfig。