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.
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 --tagsReplace 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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
