Reputation: 4451
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.
Upvotes: 57
Views: 55548
Reputation: 1328982
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 neededWhen 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.
See more at "Git author Unknown".
Note that the user.name
and email are guessed and put in that <user>/.gitconfig
file, as per commit 8b27ff7:
config --global --edit
on guessed identityWhen 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
anduser.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
Upvotes: 7
Reputation: 127
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/
Upvotes: 1
Reputation: 22552
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
Upvotes: 21
Reputation: 4222
$ git config --global user.name "Scott Chacon"
$ git config --global user.email "[email protected]"
Upvotes: 113