top of page
Adan Patience

where-did-my-github-contributions-go

If you’re anything like me, your GitHub contributions are a very important component of your career and your portfolio as a software engineer. And though it might not be like this for everyone, can we at least just admit that seeing a heat map in all shades of green just feels so good.

This came up in during the usual Friday coffee conversations at work. After seeing my colleagues contributions, I was so pumped to check mine out, because well you know, I also use GitHub professionally. With much eagerness and optimism, I signed in, and honestly, I wasn’t expecting levels of Dan Springmeyer, but I wasn’t prepared for the sea of white that I was about to see…


GitHub Contribution History Dan Springmeyer for 2020

GitHub Contribution History Yobooooi


After hours of sobbing, I thought this cant be. Made a fresh pot of coffee, dusted off my mechanical keyboard and opened my terminal and began typing with the ferocity of the NCIS agents getting hacked.

To get to the bottom of this mystery, I took a month in my contribution history where I could see there was no record of any contributions, which in this case was October. Checked for a repository I worked on in that month and ran a git log and noticed something funny. It took me a while to notice. I hope you caught it, well if you’ve not, notice not all the commits have a email associated with the Author of the commit. GitHub uses either your primary email address of your profile or the username@users.noreply.github.com email address to determine which GitHub profile committed this change.


1

$ git log --abbrev-commit

2


3

commit 9cf6b4d

4

Author: Adan Patience

5

Date: Sun October 23 19:57:23 2021 +0200

6


7

    CHORE: updated userdata

8


9

commit bca2b8d

10

Author: Adan Patience

11

Date: Sun October 23 19:57:11 2021 +0200

12


13

    FEAT: Added instance refresh and specific filter

14


15

commit 929e0b7

16

Author: Adan Patience

17

Date: Sun October 23 11:42:08 2021 +0200

18


19

    CHORE: Removed depricated syntax and refactored resources

20


21

commit 383f7e2

22

Merge: 24366ab ad2ef08

23

Author: Adan Patience <yobooooi@users.noreply.github.com>

24

Date: Sat October 22 14:33:56 2021 +0200

25


26

    CHORE: updated documentation

Now this can change for a number of reasons, in my case I was using two machines at the time and just shared the SSH keys instead of running a github config to set my global username and email address. This could also happen if you mix up your git local or global configs. As a result you could commit as author A to repository B and visa versa. So be sure to get your git configs under control. See an example below.


1

[user]

2

3

    name = Adan Patience

4


5

[filter "lfs"]

6

    process = git-lfs filter-process

7

    required = true

8

    clean = git-lfs clean -- %f

9

    smudge = git-lfs smudge -- %f

10


11

[includeIf "gitdir:/Users/adan/Work/clients/project_a/"]

12

    path = /Users/adan/Work/clients/project_a/.gitconfig

13


14

[includeIf "gitdir:/Users/adan/Work/clients/project_b/"]

15

    path = /Users/adan/Work/clients/project_b/.gitconfig

But alas, we’re here to solve a problem. So where to from here, well luckily the internet has very smart people. I found this article on StackOverflow on how to amend a commit and fast forward the repository with the new changes. I’ve included the code below on how to do it.

1

# Check the Git Log

2

$ git log --abbrev-commit

3


4

# Checkout the commit we are trying to modify.

5

$ git checkout {{ old_commit }}

6


7

# Make the author change.

8

$ git commit --amend --author "New Author Name <New Author Email>"

9


10

# Now we have a new commit with hash assumed to be 42627abe.

11

# Checkout the original branch.

12

# Replace the old commit with the new one locally.

13

$ git replace {{ old_commit }} {{ new_commit }}

14


15

# Rewrite all future commits based on the replacement.

16

$ git filter-branch -- --all

17


18

# Remove the replacement for cleanliness.

19

$ git replace -d {{ old_commit }}

20


21

# Push the new history (only use --force if the below fails, and only after sanity checking with git log and/or git diff).

22

$ git push --force-with-lease

Now that the sauce is awesome, there are 2 caveats. Its tedious, and the change is a new commit. Like everything in life, we can’t change the past and stuff. But hopefully this year your contribution will be 50 shades greener.

17 views0 comments

Comments


Commenting has been turned off.
bottom of page