How do I change my author name on GitHub?

GitGithub

Git Problem Overview


I'm new to web development and GitHub. When I commit any changes, these changes are reflected on my GitHub repo under "unknown (author)". How do I change this to reflect my name/email address?

Thanks.

Git Solutions


Solution 1 - Git

$ git config --global user.name "Scott Chacon"
$ git config --global user.email "[email protected]"

Solution 2 - Git

Add something like this to a file called ~/.gitconfig (in your home directory):

[user]
name = USERNAME
email = EMAIL_ADDRESS

where USERNAME and EMAIL_ADDRESS are filled in appropriately

Solution 3 - Git

Note that starting Git 2.2 (Q3/Q4 2014), and commit 9830534 by Matthieu Moy (moy), you will be naturally guided to enter a user and email:

config --global --edit: create a template file if needed

> When the user has no ~/.gitconfig file, git config --global --edit used to launch an editor on an nonexistant file name.

> Instead, create a file with a default content before launching the editor.
The template contains only commented-out entries, to save a few keystrokes for the user. If the values are guessed properly, the user will only have to uncomment the entries.

> Advanced users teaching newbies can create a minimalistic configuration faster for newbies.
Beginners reading a tutorial advising to run "git config --global --edit" as a first step will be slightly more guided for their first contact with Git.


If you put your GitHub username and email account in those settings, your commits will accurately reflect your GitHub account as the right author.

Note that the user.name and email are guessed and put in that /.gitconfig file, as per commit 8b27ff7:

commit: advertise config --global --edit on guessed identity

> When the user has no user-wide configuration file, it's faster to use the newly introduced config file template than to run two commands to set user.name and user.email. Advise this to the user.

> The old advice is kept if the user already has a configuration file since the template feature would not trigger in this case.

New advice:

> Your name and email address were configured automatically based on your username and hostname.
Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the following command and follow the instructions in your editor to edit your configuration file:"

git config --global --edit

> After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

Solution 4 - Git

Git uses your username to associate commits with an identity. The git config command can be used to change your Git configuration, including your username. Here is a good guide available: https://help.github.com/articles/setting-your-username-in-git/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionoxoView Question on Stackoverflow
Solution 1 - GitOriView Answer on Stackoverflow
Solution 2 - GitLee NethertonView Answer on Stackoverflow
Solution 3 - GitVonCView Answer on Stackoverflow
Solution 4 - GitJishnu DeyView Answer on Stackoverflow