4

三种方式 轻松设置 Git 提交者 email等信息 - 技术小黑屋

 2 years ago
source link: https://droidyue.com/blog/2021/06/28/multiple-ways-to-set-git-author-email/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

三种方式 轻松设置 Git 提交者 Email等信息

Jun 28th, 2021

git 配置的三种作用范围

  • 项目级,英文为project.
  • 全局(当前用户),英文为 global.
  • 系统级(针对所有用户),英文为system.

项目级配置

为当前项目设置[email protected] 作为代码提交者的邮箱。

git config user.email "[email protected]"

检索一下设置,进行验证是否成功

git config --get user.email
[email protected]
  • 该设置只针对于当前项目,其他项目不生效。
  • 该项目对应的远程地址再次clone 下来的项目也不生效。
  • 该修改不会随着git push推送到远程服务器中。
  • 配置设置持久化在当前项目的.git/config文件中。

我们为当前用户设置默认的代码提交者的邮箱(即例子中除A项目外的)

git config --global user.email "[email protected]"

再次检索一下配置是否生效

git config --global --get user.email
[email protected]
  • 该配置方式只对当前用户生效,其他用户不生效。
  • 配置设置持久化在~/.gitconfig文件中。

系统级设置

这是一种为所有的用户和项目设置默认git配置的方式

sudo git config --system user.email "[email protected]"

再次验证一下配置是否生效

git config --system --get user.email
[email protected]
  • 这种设置需要使用root权限
  • 配置设置持久化在/etc/gitconfig中。
  • 一般情况下这种配置使用频率不高。
droidyue_gzh_green_png.png

加入技术小黑屋官方电报群

Posted by androidyue Jun 28th, 2021Git, svn

« Android WebView 获取网页源码 实践与问题解决


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK