在 Git 中更改电子邮件地址

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37805621/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:16:16  来源:igfitidea点击:

Change email address in Git

gitemailjenkinsgit-stash

提问by mani_nz

I have a project hosted in Git stash. It is built using jenkins. Now I made a typo while installing my Git locally. Like @ab.com instead of @abc.com

我有一个托管在 Git stash 中的项目。它是使用詹金斯构建的。现在我在本地安装 Git 时犯了一个错字。喜欢@ab.com 而不是@abc.com

After every build, jenkins sends email notifications and it picks up my incorrect email address from Git commit and tries to send it.

每次构建后,jenkins 都会发送电子邮件通知,它会从 Git 提交中获取我不正确的电子邮件地址并尝试发送它。

Even after I have changed the email address in my local Git, I still see jenkins sending the emails to the old incorrect address.

即使我在本地 Git 中更改了电子邮件地址,我仍然看到 jenkins 将电子邮件发送到旧的错误地址。

How can I fix this?

我怎样才能解决这个问题?

回答by Marc

Locally set email-address (separately for each repository)

本地设置电子邮件地址(每个存储库单独设置)

  1. Open Git Bash.

  2. Change the current working directory to the local repository in which you want to set your Git config email.

  3. Set your email address with the following command:

  1. 打开 Git Bash。

  2. 将当前工作目录更改为要在其中设置 Git 配置电子邮件的本地存储库。

  3. 使用以下命令设置您的电子邮件地址:

git config user.email "[email protected]"
  1. Confirm that you have set your email address correctly with the following command.
  1. 使用以下命令确认您已正确设置您的电子邮件地址。
git config user.email

Globally set email-address (only used when nothing is set locally)

全局设置电子邮件地址(仅在本地未设置任何内容时使用)

  1. Open Git Bash.

  2. Set your email address with the following command:

  1. 打开 Git Bash。

  2. 使用以下命令设置您的电子邮件地址:

git config --global user.email "[email protected]"
  1. Confirm that you have set your email address:
  1. 确认您已设置电子邮件地址:
git config --global user.email

Or using environment variables

或者使用环境变量

  1. [email protected]
  2. [email protected]
  1. [email protected]
  2. [email protected]

PD: Info from github official guide

PD:来自github官方指南的信息

回答by Donald L Wilson

According to the git documentation all you should have to do is re-run

根据 git 文档,您所要做的就是重新运行

$ git config --global user.name "John Doe"  
$ git config --global user.email [email protected]  

Then just check to make sure the change took effect

然后只需检查以确保更改生效

$ git config --list

This is listed in

这列在

1.6 Getting Started - First-Time Git Setup

1.6 入门 - 首​​次 Git 设置

回答by user3143487

use

"git -c user.name="your name" -c [email protected] commit --amend --reset-author"

"git -c user.name="你的名字" -c [email protected] commit --amend --reset-author"

回答by Endriyas

To set your global username/email configuration:

要设置您的全局用户名/电子邮件配置:

  1. Open the command line.
  2. Set your username:

    git config --global user.name "FIRST_NAME LAST_NAME"

  3. Set your email address:

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

  1. 打开命令行。
  2. 设置您的用户名:

    git config --global user.name "FIRST_NAME LAST_NAME"

  3. 设置您的电子邮件地址:

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

To set repository-specific username/email configuration:

设置存储库特定的用户名/电子邮件配置:

  1. From the command line, change into the repository directory.
  2. Set your username:

    git config user.name "FIRST_NAME LAST_NAME"

  3. Set your email address:

    git config user.email "[email protected]"

  4. Verify your configuration by displaying your configuration file:

    cat .git/config

  1. 从命令行,切换到存储库目录。
  2. 设置您的用户名:

    git config user.name "FIRST_NAME LAST_NAME"

  3. 设置您的电子邮件地址:

    git config user.email "[email protected]"

  4. 通过显示您的配置文件来验证您的配置:

    猫.git/配置

For more information and for other version control systems .. => SeeThis

有关更多信息和其他版本控制系统.. => SeeThis

回答by Jan Pytlík

Edit your email directly in the JENKINS_HOME/users/YOUR_NAME/config.xmlconfiguration file and restart the Jenkins server

直接在JENKINS_HOME/users/YOUR_NAME/config.xml配置文件中编辑你的email并重启Jenkins服务器