Home > Blockchain >  Cannot set Git config with name and surname?
Cannot set Git config with name and surname?

Time:03-28

I followed these steps and when I check the commits, GitHub displays my username instead of Name Surname. Is there any missing steps or problem with these steps?

  1. I created a repo on Github without adding any file (.gitignore or Readme.md).

  2. I clone this repo to my local repo.

  3. I use cd my-new-repo and then setup username and mail as shown below:

git config user.name "Name Surname" 
git config user.email "[email protected]"

Then I checked the config via git config --list command and observe the changes.

  1. I add some files and then commit and push changes to the remote repository. However, the commits that I made after setting user config is shown by my username. So, I do not want to use global config and I think I setup user details properly as local. What is wrong?

CodePudding user response:

GitHub attributes commits to a user based on the email address set in the commits (which usually comes from the user.email entry). If your commit contains an email which is associated with a GitHub account, then GitHub will show it with the username.

If your email is not associated with any GitHub account, GitHub will show it with the name in user.name, which is traditionally a personal name (in your case, a given name and a surname), not a username. The personal name is still part of the commits, and can be seen with git log.

The way that GitHub shows commits is not configurable, but traditionally it's desirable to use an email associated with your account, so in most cases, GitHub will use your username to display things, not your personal name.

  • Related