美文网首页
git config

git config

作者: 沉默羔羊121 | 来源:发表于2020-07-15 14:59 被阅读0次

git config

首先,说下最常用的设置用户名和邮箱的命令

git config --global user.name 'xxx' //设置用户名
git config --global user.email 'xxx@gmail.com' //设置邮箱
这是针对系统某个用户的全局设置。实际上,配置用户的地方可不止全局这一个地方。

在我们首次使用Git时,都是需要配置用户名(user.name)和邮箱(user.email)的。对于用户名和邮箱来说,有3个地方可以设置

/etc/gitconfig,使用git config --system,这个是针对整个系统生效的,几乎不会使用
~/.gitconfig,使用 git config -- global,这个是针对用户的,对系统中这个用户的所有项目都生效,很常用
在项目的.git/config中设置,使用git config -- local,这是针对某个项目设置用户名和邮箱的
我们可以使用git config查看配置帮助

Davids-MacBook-Pro-2015:root macbook$ git config 
usage: git config [<options>]

Config file location
    --global              use global config file  
    --system              use system config file
    --local               use repository config file  
    --worktree            use per-worktree config file
    -f, --file <file>     use given config file
    --blob <blob-id>      read config from given blob object

总结

/etc/gitconfig|git config --system
git config --system|git config -- global
.git/config|用git config -- local

相关文章

网友评论

      本文标题:git config

      本文链接:https://www.haomeiwen.com/subject/laodhktx.html