AlexSun.dr
AlexSun.dr

Reputation: 61

Any way to change Author e-mail in VS code for git commits?

Vars summary: I am using corporate machine (corp.company.com) with VS Code installed on it (win10), using VSTS (Azure DevOps) with hosted there git which belongs to another organization (another.com). Global and local Gitconfig is configured to use [email protected] as user.email since VSTS accepts commits only from @another.com (policy).

The problem is that when I try to commit and push to VSTS from VScode, author of commits becomes [email protected] and push is failing due to policy described above. When in VScode executing commit and push via Terminal (WSL), it is all working fine and commits are saved as by [email protected].

I rebuilt local repo multiple times (by cloning remote repo), disabled credentials helper. Still when committing and pushing with VScode author becomes [email protected], when committing via cli then all is good - [email protected].

Btw [email protected] is the same as username for logging into the Win machine. I checked Windows Credentials Manager and for git it is also [email protected]. [email protected] is only set for O365 creds there.

Anyone?

Upvotes: 1

Views: 5666

Answers (1)

Vito Liu
Vito Liu

Reputation: 8298

We could check the commit Author info via the git cmd.

git config user.name // Check your user name
git config user.email // Check the associated email

You could run it cmd to check the commit owner, in your vs code, it should be [email protected], we need to change the email address to [email protected] via git config user.email "[email protected]", you need to change it, run the cmd to check the email address and ensure the result is @another.com, then it will work.

git cmd

git config user.name "newemail"
git config user.email "[email protected]"

Result:

enter image description here

update1

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

The above will be a global change meaning that it'll change it for all git projects

Update2

VS code push the commit via git, If we update the git configuration, and it will change the VS code configuration. This is my test steps, you could check it.

enter image description here

Change the commit Author info via the git cmd and result

enter image description here

Upvotes: 6

Related Questions