在Git中更改电子邮件地址

yshpjwxd  于 2023-05-21  发布在  Git
关注(0)|答案(6)|浏览(304)

我在Git stash中托管了一个项目(现在更名为Bitbucket Server)。它使用Jenkins构建。现在我在本地安装Git时犯了一个错字。例如@ab.example而不是@abc.example
每次构建完成后,Jenkins都会发送电子邮件通知,它会从Git commit中获取我不正确的电子邮件地址并尝试发送。
即使我在本地Git中更改了电子邮件地址,我仍然看到Jenkins将电子邮件发送到旧的错误地址。
我该怎么解决这个问题?

vqlkdk9b

vqlkdk9b1#

本地设置邮箱地址(每个仓库单独设置)

1.打开Git Bash
1.将当前工作目录更改为您要在其中设置Git配置电子邮件的本地存储库。
1.使用以下命令设置您的电子邮件地址:

git config user.email "your_email@abc.example"

1.使用以下命令确认您已正确设置电子邮件地址。

git config user.email

全局设置邮箱地址(只在本地没有设置的情况下使用)

1.打开Git Bash
1.使用以下命令设置您的电子邮件地址:

git config --global user.email "your_email@abc.example"

1.确认您已设置电子邮件地址:

git config --global user.email

或者使用环境变量

  1. GIT_COMMITTER_EMAIL=your_email@abc.example
  2. GIT_AUTHOR_EMAIL=your_email@abc.example
    PD:来自GitHub官方指南的信息
ctehm74n

ctehm74n2#

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

$ git config --global user.name "John Doe"  
$ git config --global user.email johndoe@example.com

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

$ git config --list

这列在**Pro Git**书中,由 Scott ChaconBen Straub 撰写
1.6入门-First-Time Git Setup

a6b3iqyw

a6b3iqyw3#

使用
“git -c user.name =“您的姓名”-c user.email youremail@email.com commit --amend --reset-author”

pxy2qtax

pxy2qtax4#

要设置全局用户名/电子邮件配置,请执行以下操作:
1.打开命令行。
1.设置您的用户名:
git config --global user.name "FIRST_NAME LAST_NAME"
1.设置您的电子邮件地址:
git config --global user.email "MY_NAME@example.com"
要设置特定于存储库的用户名/电子邮件配置,请执行以下操作:
1.在命令行中,切换到存储库目录。
1.设置您的用户名:
git config user.name "FIRST_NAME LAST_NAME"
1.设置您的电子邮件地址:
git config user.email "MY_NAME@example.com"
1.通过显示配置文件验证配置:
cat .gitconfig
有关更多信息和其他版本控制系统。=> SeeThis

qmelpv7a

qmelpv7a5#

下面的命令在.git/config文件中设置email地址:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
        url = https://username:password@git.mydomain.io/username/repo.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[branch "beta"]
        remote = origin
        merge = refs/heads/beta
[user]
        email = pippo.caio@sempronio.io
1l5u6lss

1l5u6lss6#

直接在JENKINS_HOME/users/YOUR_NAME/config.xml配置文件中编辑您的电子邮件并重新启动Jenkins服务器

相关问题