仿阿里云网站,惠州惠阳网站建设,公司网站去哪里做,上海网站公司建设git config的范围参数: local, global, system1. --local: 作用于当前仓库2. --global: 作用于当前用户的全局范围的 Git 仓库3. --system: 作用于系统范围内的 Git 仓库4. 注意事项参考链接1. --local: 作用于当前仓库
--local: 这个参数的作用范围是当前仓库。其配置的参数保…
git config的范围参数: local, global, system1. --local: 作用于当前仓库2. --global: 作用于当前用户的全局范围的 Git 仓库3. --system: 作用于系统范围内的 Git 仓库4. 注意事项参考链接1. --local: 作用于当前仓库
--local: 这个参数的作用范围是当前仓库。其配置的参数保存在当前 git 仓库下的 .git/config 中只对当前仓库有效。
示例指令
git config --local user.name myNameLocal
git config --local user.email 1234xxx.com执行完上述指令之后文件.git/config 中会增加如下两行内容 2. --global: 作用于当前用户的全局范围的 Git 仓库
--global: 作用于当前用户的全局范围的 Git 仓库。其配置的参数保存在当前用户下的 ~/.gitconfig 中只对当前用户有效。
示例指令
git config --local user.name myNameGlobal
git config --local user.email 1234123xxx.com执行完上述指令之后文件~/.gitconfig 中会增加如下两行内容 3. --system: 作用于系统范围内的 Git 仓库
--system: 作用于当前系统范围的 Git 仓库。其配置的参数保存在系统下的 /etc/gitconfig 中对当前系统中的所有用户有效。注意修改系统配置通常需要sudo权限。
示例指令
sudo git config --system user.name myNameSystem
sudo git config --system user.email 123412312xxx.com执行完上述指令之后文件/etc/gitconfig 中会增加如下两行内容 4. 注意事项
这三种配置只配置其中一个就可以正常使用git。笔者一般使用--global参数对git进行配置。可以通过git config --list指令进行查看当前的 git 配置.
比如可以使用下列指令查看--local 配置的参数
git config --list --local终端输出结果
当存在多个配置时或者当这个三种配置都已经进行配置了git 对于这三者有如下的优先级: local global system , 也就是 配置到当前仓库--local的参数优先级最高。
参考链接
[1] 极客教程. Git 修改git config [EB/OL]. https://geek-docs.com/git/git-questions/531_git_resetting_git_config.html, xxxx-xx-xx/2025-08-12.