Recently, when I showed my Contributions to my classmates on Github, I suddenly found that there were only two or three small green blocks in the blank of my Contributions Graph, because the records of my daily work in the company would be displayed on the Graph. Git has not set the correct user name and email address when it is initialized. For details, see Github’s help documentation

Why are your Contributions not shown in your Profile?

The question is, what are Contributions? Github has a quote on its website:

Your profile contributions graph is a record of contributions you’ve made to GitHub repositories. Contributions are only counted if they meet certain criteria. In some cases, we may need to rebuild your graph in order for contributions to appear.

The contribution chart in your profile records your contributions to the repository on Github. It only records certain commits that meet the standard. In some cases, we will need to re-create your contribution graph so that all contributions are displayed.

What kind of contributions are counted by Github?

Students who are good at English, please move. Why are my contributions not showing up on my profile?

Issues and pull requests

  • This operation is within a year

  • This operation is for a single repository, not a fork

Commits

A. Commits Should be displayed when your commits meet the following conditions:

  • Commits submitted within one year

  • Commits used email addresses associated with your Github account

  • These commits were in an isolated barn, not a forked barn

  • These commits are in:

    • On the default branch (usually master)

    • In the GH-Pages branch (repository containing Project Pages Sites)

In addition, at least one of the following conditions must be met (the repository that you did not create is primarily for your Commit) :

  • You are either a collaborator of the repository or a member of the owning organization of the repository

  • You forked this warehouse

  • You have initiated a pull request or issue on this repository

  • You marked the warehouse with Star

Note: Contributions from private libraries are shown only to private library members

There are several common reasons why Contributions are not included in Github

  • The user who committed Commits was not associated with your Github account.

  • A Commit is not made in the default branch of this repository.

  • The repository is a Fork rather than a stand-alone repository.

How to troubleshoot

You can use git log in your local repo to check whether the personal email address on the commit record is correct. For example, my email address on the commit record is always [email protected] because my user name was not configured after switching to Mac platform for development. So Github would think that none of the commits were from you!

Remedial measures

Changing author info: Changing author info: Changing author info: Changing author info: Changing author info

Change author information

To change the user name and/or email address of existing commits, you must rewrite the entire history of your Git repo.

Warning: This behavior is destructive to the history of your repo. Rewriting published history is a bad habit if your REPO is working in collaboration with others. Perform this operation only in emergencies.

Using a script to change your Repo’s Git history We wrote a script that changed the commit author’s old email address to the correct username and email address.

Use scripts to change the Git history of a repo

We have created a script that, after submitting with the correct name and email address, should correct author information in all commits that you previously submitted and old usernames and email addresses in the Commits field

Note: Executing this script overwrites the history of all the collaborators in the REPO. After doing the following, anyone forking or clone must retrieve the rewritten history and rebase all local changes into the rewritten history.

Before executing this script, you need to prepare the following information:

  1. Open Terminal in Mac and Linux. Open Command Prompt in Windows.

  2. Create a new clone git clone –bare github.com/user/repo.g… cd repo.git

  3. Copy and paste the script and modify the following variables based on your information: old Email address, correct username, correct Email address

    #! /bin/sh git filter-branch --env-filter 'OLD_EMAIL=" old Email address "CORRECT_NAME=" correct user name" CORRECT_EMAIL=" correct Email address "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 --tagsCopy the code
  4. Press Enter to execute the script.

  5. Use git log to check the new Git history for errors

  6. Push the correct history to Github

    git push --force --tags origin 'refs/heads/*'Copy the code
  7. Delete the clone created temporarily

    cd ..
    rm -rf repo.gitCopy the code

How to set up your Git profile

Next, set up your correct information globally, and don’t worry about using Github for version management

Git config --global user.email "git config --global user.name"Copy the code

Pro Git 8.1 Customize Git

Please note the original link: xunli.xyz/2016/01/09/…