简体   繁体   中英

GitHub - How to link commits to my account?

I've noticed that all my githubs commits would appear with my name, but not associetad with my account. The same problem as this: Git commits are not getting linked with my GitHub account

I followed those steps and fixed that problem. However, the old commits are still not linked to my account. Since this was for over 1 year, i would really need for them to be linked (nowadays the github profile is very important and mine looks empty, like i've not worked that year ...)

Is there any command to associate every commit from every repository i've made in that time?

Thanks for your time

Okay, sorry for the delay, but since I eventually figured this out, through mail exchange with git staff (and found it quite useful) I will share how to fix this!

So, if for some reason the git settings you were committing with were off and you can't see your commits in your profile and in the repos they are not linked to your account, this is how to do it (I will assume at this point, that you have fixed your configs in your terminal, so future commits will be correctly linked, if not just follow this tutorial ).

  1. Go to the desired repo, click 'Commits' and click in one of your commits (one that is not linked to your account).
  2. Add to the end of your URL ".patch" . This way it will open the information relative to that commit and you can see (in the second line) with which username and email you have commited
  3. Now that you now what part is off, you only need to follow this 'Changing author' tutorial
  4. Just to help with that tutorial, the idea is to use the email you just saw in the '.pacth' page as OLD_EMAIL and you GitHub config email as your 'CORRECT_EMAIL'
#!/bin/sh

git filter-branch --env-filter '

OLD_EMAIL="email you just saw in .patch"
CORRECT_NAME=“correct username, you can check it in your terminal git config --global user.name”
CORRECT_EMAIL=“correct email, you can check it with git config --global user.email”

if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags

Hope it helps, this fixes every commit you made with the wrong email in one repo, so if you've this trouble in multiples, you will have to do it once in every single one (and one time for each different wrong email you've committed with). Any doubt just ask :)

You must make sure that the email associated with your commit is the same as the one one your Github profile.

To check the email address currently associated with your git commits:

git config --global user.email

To modify the email address associated with your git commits:

git config --global user.email "my@email.com"

Note that changing your email address will not change the email associated with your old commits. You could instead add the old email address to your Github profile as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM