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

前端 未结 27 1156
南笙
南笙 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:31

    The "Contributions Calendar" or "Activity overview" on github is only recording the commits that are related to the mail address that is recorded in the github account.

    Change the mail address for all future commits

    As already noted by many others in this thread, look up the current locally saved email address by:

    git config user.email
    

    If it doesn't match the mail on github, change using:

    git config --global user.email my_email@gmail.com
    

    This will globally change the mail address for all future commits but will not affect the "Contributions Overview" for the past ones. You can follow the official docs for an extended description.

    Change the mail address to update the overview for the past commits

    You realize that many of your past commits have not been recorded correctly in the Github "Contributions Overview":

    To change that, you can change the author info for the repositories by following the steps explained in the official github docs.

    A short summary:

    1. Open git bash
    2. Clone a bare repository

      git clone --bare https://github.com/user/repo.git
      cd repo.git
      
    3. Paste the following code into the git bash console after changing the variables OLD_EMAIL, CORRECT_NAME and CORRECT_EMAIL:

      #!/bin/sh
      
      git filter-branch --env-filter '
      
      OLD_EMAIL="your-old-email@example.com"
      CORRECT_NAME="Your Correct Name"
      CORRECT_EMAIL="your-correct-email@example.com"
      
      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
      
    4. Press enter to run the script

    5. Push the corrected history to github
      git push --force --tags origin 'refs/heads/*'
      

    This procedure should update the "Contributions Overview" and now also show the commits not shown before:

    Warning: This action is destructive to your repository's history. If you're collaborating on a repository with others, it's considered bad practice to rewrite published history. You should only do this in an emergency.

提交回复
热议问题