Override Git's user.name by project

How can we override user.name of Git by project?

Specifying GITPOD_GIT_USER_NAME at https://gitpod.io/settings/ does not help.

cf. GITHUB_USER_NAME - Env Variable

Hey @tnir! Try using GIT_AUTHOR_NAME and GIT_COMMITTER_EMAIL. Then you can specify a project like group/project in the last column.

1 Like

Thanks @gtsiolis, but unfortunately does not work to me… My setting is as follows:

and the results I got:

$ git config -l
push.default=simple
alias.lg=log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
credential.helper=/usr/bin/gp credential-helper
user.name=tnir
user.email=takninnovationresearch@gmail.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://gitlab.com/gitlab-org/gitlab-development-kit.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

I used to launch gitpod workspaces for this repo (gitlab.com/gitlab-org/gitlab-development-kit) multiple times while all existing workspaces were confirmed as deleted before launching a new workspace…

Hey @tnir! The approach mentioned above is based on environment variables that override git configuration. You can see all available variables within a workspace by running:

gp env

@gtsiolis Umm, the results are as follow:

$ gp env
GIT_AUTHOR_NAME=Takuya Noguchi
$ env |grep -i tak
GIT_AUTHOR_NAME=Takuya Noguchi
GITPOD_GIT_USER_EMAIL=takn**[reducted]**@g***l.com

Cofirmed on the public repos gitlab.com/gitlab-org/gitlab and gitlab.com/gitlab-com/www-gitlab-com.

Both are specifying the .gitpod.yml: https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitpod.yml & https://gitlab.com/gitlab-com/www-gitlab-com/-/blob/master/.gitpod.yml

Looks good @tnir! If you also need to change the author email for commits in all or a specific project you can use the GIT_COMMITTER_EMAIL environment variable which will override GITPOD_GIT_USER_EMAIL.

1 Like