Fundamentals 4 min read

Why Your GitHub Contributions Aren’t Showing and How to Fix It

This guide explains why GitHub may not display the green contribution squares after a commit—typically due to mismatched email or username settings—and provides step‑by‑step commands and scripts to correct global or repository‑specific Git configurations and rewrite history so the contributions appear correctly.

Programmer DD
Programmer DD
Programmer DD
Why Your GitHub Contributions Aren’t Showing and How to Fix It

Sometimes after pushing code the small green square on your GitHub profile does not increase, which is usually caused by a mismatch between the email/username configured in Git and the one associated with your GitHub account.

Solution 🎉

There are two simple ways to fix the issue:

Modify the global Git configuration:

git config --global user.name "ordinaryA"
git config --global user.email "[email protected]"
Using the --global flag changes the default name and email for all repositories on this machine; you can also set a different name/email for a single repository.

Modify the configuration of a single repository:

cd .git
git config user.name "ordinaryA"
git config user.email "[email protected]"

After updating the configuration, new commits will show the green square on GitHub.

To make past commits display correctly, rewrite the history to replace the old email with the correct one:

#!/bin/sh

git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="ordinaryA"
CORRECT_EMAIL="[email protected]"

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
Replace OLD_EMAIL with the email used in the old commits, and set CORRECT_NAME and CORRECT_EMAIL to your GitHub name and email.

Run the script, then verify the changes with git log. Finally, force‑push the rewritten history: git push origin --force --all After these steps the contribution graph on GitHub will correctly reflect both past and future commits.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

GitHubContribution GraphEmail Configuration
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.