DEV Community

Cover image for Faking GitHub Contributions
Yuki Shindo
Yuki Shindo

Posted on

Faking GitHub Contributions

NOTES: This post is a joke.
And, I haven't gone through GitHub's specifications in detail, so this may not be the best way to do it.


Imagine.
Suppose you've been diligently working on Contributions every day on GitHub.

Unfortunately, you're busy with something else that day and you forget to color in your Contributions graph.
You can't help but wonder if you can't find a way to color in the blank graph.
(As an image, here's what I'm imagining below; October 30 is left blank.)

Contributions image

Tampering with AuthorDate and CommitDate in Git's Commit History

I didn't check GitHub's specs in detail, but I assume the GitHub Contributions refer to Git's commit time.
In this article, we're going to try to falsify the original Contributions by setting up a new repository and falsifying the commit time in that repository.

I'll describe the procedure in the following paragraphs.

1. Creating a new repository on GitHub

2. Clone the repository locally.

3. Make a commit (whatever it is content)

4. Tampering with AuthorDate and CommitDate in Git

Here's the actual command I typed.

GIT_COMMITTER_DATE="Fri Oct 30 12:30:27 2020 +0900" git commit --amend --date="Fri Oct 30 12:30:27 2020 +0900"
Enter fullscreen mode Exit fullscreen mode

GIT_COMMITTER_DATE="Fri Oct 30 12:30:27 2020 +0900" is CommitDate rewritten into the specified time.

Also, --date="Fri Oct 30 12:30:27 2020 +0900" is AuthorDate rewritten into the specified time.

In this case, the same time is specified in both cases.

5. Check AuthorDate and CommitDate have been changed.

When you run this command, you'll see that AuthorDate and CommitDate have been changed.

git log -1 --pretty=fuller
Enter fullscreen mode Exit fullscreen mode

6. Push to a remote repository on GitHub

In the image below, you can see that the contributions that didn't really exist have been added.

Contributions image 2

Here is the actual repository where this work was done.

shinshin86/timemachine-joke-20201031

Epilogue

The day I did this was Halloween.
I wanted to do some kind of prank-like (trick-or-treating-inspired) joke, so I challenged myself to do it.

It's just a joke!
So it's best not to do it in a real work :)

Top comments (0)