I just switched to OS X and did my first commit. After pushing to Github the commit author was not my Github username but the current user on my laptop. The commit author appears as "non-author". I want the commit author to be my Github username like before. What should I do to fix it? Here is a photo of what I mean: https://i.sstatic.net/LLEph.png
5 Answers
While Tilak's answer solves your problem, it doesn't tell you why. This answer is mainly for this purpose.
First thing is: GitHub and Git ARE NOT the same thing.
This is a common mistake. Git is the versioning management tool, while GitHub is a service which provides a Git server on the cloud. Others include Bitbucket and GitLab.
Second thing is:
The default user for commits is the one you run git with. So if, for instance, you executed sudo git commit, the user would be root. What you need to do is, as the accepted answer suggests, configure the username you want, which has nothing to do with your GitHub account, it could be any name.
Third thing is:
The non-author issue is due to the fact that GitHub matches the email of the user that created the repository ON THEIR SIDE and the email of the committer, again, configurable by means of the accepted answer's suggestion. But, your Git user.email configuration has nothing to do, again, with GitHub. It's just used to differentiate repository creator's commits from collaborator's commits.
Comments
Despite setting user and email in config, it continued to use the system account name until this:
git config user.useConfigOnly true
user.useConfigOnlyInstruct Git to avoid trying to guess defaults for user.email and user.name, and instead retrieve the values only from the configuration. For example, if you have multiple email addresses and would like to use a different one for each repository, then with this configuration option set to true in the global config along with a name, Git will prompt you to set up an email before making new commits in a newly cloned repository. Defaults to false.
Comments
Adding to Tilak's answer, you may also have to re-define local config values if they have already been declared. Execute the following within whatever repo you are currently working:
git config user.email "[email protected]"
git config user.name "name"
If you already tried changing the local user.name config value within your current repo it will overwrite the global value. So when you execute git config -l you could see duplicate user.name and user.email values. If both exist, then make sure they are both defined how you want them.
Comments
git config --global user.email "your Email"
git config --global user.name "you GitHub ID"