Global Git Email

I want to globally set my git push email on gitpod via the command line as laid out here: https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-github-user-account/managing-email-preferences/setting-your-commit-email-address#setting-your-commit-email-address-in-git. Is there any way to make this persist between workspaces? (I have multiple email addresses linked to my github account)

i don’t know if you can “persist” it. but you can add it on startup of gitpod.
So, i’d put the email into an environment variable in gitpod and call the git config ... thing on gitpod init

Hi @rohan-patra,

Can you check your Git integrations? Dashboard — Gitpod

Hey @rohan-patra! You can override git author name and email per project by using the default environment variables GIT_AUTHOR_NAME and GIT_COMMITTER_EMAIL. See relevant docs. :bookmark_tabs:

You can view the current configuration in /account and override this in /variables as well as define different values for specific orgs and projects.

Cc @porkus1990 @Pauline

3 Likes

Thank you! This is exactly what I was looking for!

Not sure if it would be better to create a new topic, but my issue is very similar, so just posting it here.
So I’ve set the environment variables
GIT_AUTHOR_NAME
GIT_COMMITTER_EMAIL
GITPOD_GIT_USER_EMAIL (saw this somewhere, just gave it a try)
But they are not applied to the git user.name and user.email in the workspace.
gp env in the workspace shows that the environment variables are set correctly (as far as I can tell).
BTW I’m very new to gitpod, I might be missing something trivial…

Hey @HolgerSin! Have you got an example repo that we can look into?

Another thing to check is when you set these variables up, have you committed the file and pushed it and started a new workspace?

Hi @Pauline,

thanks for your reply.

Yes I do have a test repo, shall I share the link here or better by PM?

I’ve set up the environment variables at Dashboard — Gitpod, but did not commit anything there, I thought that’s a system setting, do I have to commit a file somewhere?

Whichever you feel comfortable with.

Apologies, I thought that you set the environmental variables in your .gitpod.yml file. Like here. But I just re-read your message and it looks like you put them directly in your /variables which should work too. So just ignore me there! :slight_smile:

Here’s a few screenshots to show what I’ve done:

2021-10-18 at 14.07.26 - Google Chrome

Well this looks pretty similar to what I have, only thing is the environment variables are apparently not used to actually set the git user.name und user.email. Do I need to change any setting so they are actually used?

Anmerkung 2021-10-19 083315

Here is the link to my test workspace if it helps:
https://gitpod.io/start/#amethyst-clownfish-s6u0smjv

When you commit and push and do a git log - what username and email is shown? You’re doing everything right, don’t worry. :blush:There are no additional settings or anything else, this should work.

git -log shows the new username from the environment variable (Holger_Gitpod), but as email my gmail address, not the …noreply.github.com address from the environment variable.

I notice that the git config --global user.name command still shows username Holger, although in the commit message the user name is Holger_Gitpod. I assume that behaviour is intended?

I could not push to Github due to my email privacy setting there (as expected considering the gmail address is used)

So I asked internally and someone else had a similar issue. :thinking: Sorry about this!

Here’s the related issue and open PR. It’s confusing wording on our end!

Can you try GIT_AUTHOR_EMAIL? :star:

Unfortunately, that did not do the trick. I’ve set the variables as by the picture below, but still the wrong email is used.
[Mutiple Edits as I first thought it had worked but was mistaken and had to rewrite completely…]

Final Edit (hopefully): Setting the 3 variables below and restarting the workspace worked for me.

image

Great to hear, let me know if you have any more questions!

Sorry, bit of a misunderstanding here: I first posted a reply that it worked, but was mistaken, then I corrected my post. I guess you replied to the first version.

So unfortunately the problem still persists.

Apologises, I was tracking your issue internally and it didn’t update when you edited your post.

I can’t see anything obvious here that is causing an issue, I also tried it myself and ran into the same problem with email specifically. I looked for other variables names here but no luck.

This sounds like a bug, can you file one here

Just noticed, after restarting the workspace it does work indeed. Sorry, should have checked that simple solution in the first place. Need to check further if really all 3 variables are required, will get back to you and post here…

1 Like

So final feedback (hopefully): All 3 environment variables need to be set:

GIT_AUTHOR_EMAIL
GIT_AUTHOR_NAME
GIT_COMMITTER_EMAIL

To check git log and see the differences, git log --pretty=full needs to be used (to see both author and committer email - I didn’t even know there were two of those :wink: ).

If changing the environment variables the workspace needs to be restarted, even if gp env shows the variables to be set correctly, they are apparently only applied after a restart.