4

I want to disable the option for my git users that they can set a global username and email. I want it to be empty at all.

Now I have the problem, that when some of them set the global user.name and global user.email, all the commited codes goes by the same name in every project.

How can I solve this problem?

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
arash yousefi
  • 376
  • 5
  • 16

1 Answers1

7

Global options are for each user to set (or not)

You would need for them to use, as in here:

git config --global user.useConfigOnly true

Any new repo will look for user.email only in their local .git/config file.
And the commit will not proceed if no user.email is found in the local git config.

That helps force the user define their identity in each of their repositories.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • i now managed it with ssh connection, this problem occurs when they use the http. – arash yousefi Jul 22 '20 at 06:42
  • can they still set or unset the global config settings, specially the global user.name and user.email ? – arash yousefi Jul 22 '20 at 06:48
  • 3
    @arashyousefi user.name/email config have nothing to do wth authentication though. – VonC Jul 22 '20 at 07:17
  • i know it but the global user.name will be set for all committed codes. no matter what the authentication info is. – arash yousefi Jul 23 '20 at 06:01
  • 2
    @arashyousefi I agree. But that will happen whether they use SSH or HTTPS. With the setting I propose, they will have to set explicitly their `user.name`/`email` per repository, not globally. – VonC Jul 23 '20 at 06:07