在Git中设置自己的姓名

在Git中,自己的姓名与每一个commit提交绑定在一起。如果你在使用Azure DevOps Server中的Git Repo时,一定要注意commit中的提交者与服务器上的推送者,是两个概念。

在Git中,设置自己的名字有两个层面的内容:全局设置(global),库设置。

全局设置中的设置会影响所有库,库层级的设置只会影响特定的库。

1. 设置全局属性

  • 打开命令行窗口或者git bash

git config --global user.name “张洪君“

git config -- global user.email “zhanghongjun@bjgreatsoft.com

完成上面的设置后,可以使用get参数显示设置后的信息,例如

git config - -global - -get user.name

git config - -global - -get user.email

如果使用Windows计算机,你还可以在自己用户目录下(c:userszhanghongjun)找到一个文件.gitconfig,里面保存上面的设置信息

2. 设置库层级的属性

在某些场景中,我们需要对特定的库做单独的设置,那么可以在在库层级上做下面的是指

cd myrepoFolder

git config user.name “zhanghongjunInRepo”

git config user.email “zhanghongjunInRepo@mycom.cn

同样,你可以使用get属性来获取库层级中的设置

git config – -get user.name

你也可以在Git库目录的.git文件夹中,找到config文件,里面记录了库层级的设置信息

image

--

http://www.cnblogs.com/danzhang/  DevOps MVP 张洪君

--

原文地址:https://www.cnblogs.com/danzhang/p/10778414.html