0

What is the use of config command for the user name and email in git? I don't see the point as I can put like any username and email and it accepts it without even confirming it.

It may be a silly question as I am just a beginner.

For reference the command is;

git config --global user.email "any-email.com"

Buran
  • 135
  • 1
  • 11
B Luthra
  • 153
  • 9

1 Answers1

1

The point of the config command is to set configuration values. The specific example you gave - setting the email address - is only one of many uses of the config command.

Beyond that, I'm confused by your question. You don't see the value in being able to specify the email address, because it doesn't validate the email address?

Every git commit is marked with an author name and email, and a committer name and email. You need a way to tell git what values to use when you make a commit. You could put in inaccurate values, if you think that helps you in some way; and knowing that, any project that doesn't (or shouldn't) trust you will know that it can't rely on this information for anything sensitive.

Author/committer values on a commit are not guaranteed to be accurate - you can put whatever you want in those fields. There are features for associating an identity with a commit in a verifiable way, but the basic name/email config settings aren't among them. These also are not used for access control - if you need user-based access control, your remote's hosting software may provide it.

Nonetheless, most teams use these config values to quickly identify who produced a commit, and this generally isn't something that needs cryptographic verification.

Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52