GitHub commits aren't recorded in the 'Your Contributions` calendar

前端 未结 27 1832
南笙
南笙 2021-01-29 21:59

I\'ve been making continuous commits to my GitHub repos from my linux shell and they show up nicely on the website just as they should. The only problem is that \"Y

27条回答
  •  野性不改
    2021-01-29 22:16

    I had to restore my laptop recently and forgot to reconfig my email to git. My laptop username looks similar to my git one, so I just blindly thought my commits were being attributed correctly. As posted, you can change your global email settings. However, if you want to correct the miss-attributed commits on your project, you can use this run this script to create an alias gca that you can run in your git project directory to change the authorship of your past commits.

    From your ~ directory, add:

    $ cat <> ~/.aliases
     function git_change_authorship {
     git filter-branch -f --env-filter "
      GIT_AUTHOR_NAME=\"\$1\"
      GIT_AUTHOR_EMAIL=\"\$2\"
      GIT_COMMITTER_NAME=\"\$1\"
      GIT_COMMITTER_EMAIL=\"\$2\"
     "
     }
     alias gca=git_change_authorship
     EOF
    
     $ source ~/.aliases
    

    then in your git project directory run gca

    Heads up! I have only used this in my own personal projects where I have been the sole committer. Haven't had a chance to test it out with group projects, so proceed cautiously.

提交回复
热议问题