One day you realize you’ve submitted your code, but the green bars on GitHub’s front page haven’t increased.
At first I thought it was a delay, or that I could not see my contribution points that day and they would be available the next day? 😡
GitHub Commit records and local configurations show that the user name is inconsistent with that of GitHub.
Because you submit the code in the company, the default configuration in the company is the company email, not your own email 😅
Solution 🎉
It is easy to solve the problem after finding the reason. There are two simple methods:
- Modify the user name and mailbox of the global default mailbox
git config --global user.name "ordinaryA"
git config --global user.email "[email protected]"
Copy the code
Note that if global is used, all Git repositories on your machine will use this Email address and username by default. You can also specify a different username and Email address for each Git repository.
- To modify a single
Git
The username and email address of the warehouse
Open the project directory with the bash command
cd .git
git config user.name "ordinaryA"
git config user.email "[email protected]"
Copy the code
Then run the following command to check whether the config file is successfully modified:
cat config
Copy the code
Once you’ve done that, when you submit your code again, you’ll see your little green bar on GitHub!
Done 💧
After completing the above steps, the submitted code will have a green grid, but how to retrieve the previously submitted code?
We only need to change the commit username and email address of the historical commit record to display 😀 correctly
Create email.sh in the project root directory and write the following code:
#! /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
Copy the code
Set “OLD_EMAIL” to “old email” and “CORRECT_NAME” to “old email”. You can set “OLD_EMAIL” to “old email” by “git log” or “GitHub” to “CORRECT_NAME”
Next, execute the script
./email.sh
Copy the code
Use git log to see that the mailbox has been modified successfully
After local modification, you need to push it to GitHub
Bash the following commands
git push origin --force --all
Copy the code
At this time open GitHub you will find small green grid magical recovery 😄