Git commits are not getting linked with my GitHub account

流过昼夜 提交于 2019-12-30 17:27:09

问题


I'm having problems trying to link my commits to my GitHub account. Commits are being reported on GitHub the way my picture shows. The values user.name and user.email are correct, any other ideas to check?

Thanks in advance


回答1:


Even though your settings might look correct, this error implies that something in the user.email field is incorrect, which gives Github the wrong information about who the committer is. A small typo could throw the whole thing off. The fix is in the third step, and the first two steps help identify what the problem is.

First, run git config -l to check your settings and make sure that you don't have something unexpected in there. Run git log and take note of how the Author field looks. It should be in the format of Author: Your-Name <your-github-email@example.com>. The part within the brackets is the important part as far as Github is concerned.

Second, if you've been able to commit something successfully in the past, open that repo and run git log to find the commit where everything worked properly. Check that Author field against the one that isn't working and see if there is a difference.

Third, if there is a difference, switch back to the repo at issue and run git config --global user.email correct-email@example.com.

If the problem persists, check your Github email settings and make sure that the email address that you are using is added to your account.

See this help article for more information.




回答2:


I had a similar issue and @stvnrlly response was useful. In my case when running:

git config --global user.email 

The CL would spit "email@email.com" which is wrong as it should display the email address without the "". So in my case the set-up was not properly done. Hope it helps.




回答3:


Here are the exact steps of how I solved the problem.

(1) The user.name field in my ~/.gitconfig file did not need to match what I had on Github. However, the user.email field in ~/.gitconfig needed to be an exact, letter-by-letter match to the email field on Github.

(2) The relevant email field on Github is under "Settings" (the icon on the upper right that looks like the gear) and then, rather than resetting the email in "Your Profile" (this aspect of the instructions is what confused me), I needed to actually click on the section of Settings called "Emails" and add the new email address I had in user.email. I followed the instructions on Github to verify this email address. I did not need to make this email address "primary" to fully synchronize my computer with my Github account.

File paths and names are standard for Mac OS X. Thanks @stvnrlly, I used the general gist of your answer.




回答4:


You have to get the reference for the remote repo first.

git remote add origin https://github.com/yourGithubAccount/yourRepo.git

then do git push -u origin master.




回答5:


If you received your e-mail address from gmail, and in "." If there is a sign, like me, you may have encountered such trouble. For example, if your original e-mail address is "test.code@gmail.com" and you have registered as "testcode@gmail.com" when you register with github, you are very likely to encounter this error.

As a solution; you need to link both email addresses to your github account.



来源:https://stackoverflow.com/questions/26004587/git-commits-are-not-getting-linked-with-my-github-account

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!