Back in university, I wrote a tiny Python script that generated GitHub activity for me and my friends. It successfully attracted recruiters, and helped me start countless small talks. Unfortunately, this original script is now lost in time, because I can’t find it on any of my devices or cloud storage accounts. Last Friday, after having a couple cans of fine Lebanese brew I decided to re-create that thing for fun and profit.

Anatomy of Git Commits

A commit is just a file stored inside the Git filesystem (that .git folder in all your repositories). If you’re curious about how it looks, you can take a commit hash and print its contents using git cat-file:

git cat-file commit ac0afe604567e7f49cc0deb898a1a20bcf372ec5 
tree 205f6b799e7d5c2524468ca006a0131aa57ecce7
author Rida Dzhaafar <rdzhaafar@gmail.com> 1695188611 +0300
committer Rida Dzhaafar <rdzhaafar@gmail.com> 1695188611 +0300

foo

Here is the key information that a commit contains:

  • State of the repository (tree)
  • Commit author
  • Commit timestamp (in Unix format) and timezone offset
  • Commit message

GitHub will parse the repository and find your commits by matching your email with the author email. It will then know when you’ve made that commit and count it towards your activity.

Commit from the above example was made on September 20th, 2023. You’d know that if you paste the timestamp 1695188611 into some online timestamp to date converter.

foo

Commit timestamp was taken automatically when I ran git commit. There’s an option (--date) that overrides this default behaviour. If I make a commit and pass it a date formatted in ISO8601, there’s nothing stopping me from specifying a date from before Git was written (as long as that date is after the Unix epoch).

git cat-file commit 07eb6c09c7cf72d5a5f4d42cb6f77d126bee4ce6
tree b99e384aa896b2c3431c594e2d20cc3d470314c3
parent 1b276fd61d75caac7f5fa98f03c41e8e43771c45
author Rida Dzhaafar <rdzhaafar@gmail.com> 653810475 +0000
committer Rida Dzhaafar <rdzhaafar@gmail.com> 1695190142 +0300

nineties foo

nineties foo

I assume Git initially added this feature to support exporting history from other VCSes or support rewriting history (rebasing). Regardless of the reason, this is exactly what I’m going to use to gain good boy points on the interwebs.

Writing the Generator

The implementation is very short (under 200 lines of Java), so I’ll skip walking you through every line of code. Here’s what the script boils down to:

  • Read the date of last commit from .last_write file or assume that last write happened 1 year ago in case this file wasn’t found
  • Generate a random amount of commits based on whether it’s a weekend/weekday so that activity graph looks more realistic at first glance
  • Write these commits using a git commit --date=...
  • Write the last commit date to the .last_write file

These are the results:

activity

I even included a little vacation close to November 2022 to be cute.

To automate activity generation entirely, you could even host this script on an EC2 instance and create a cronjob that will trigger it every day or so.

Disclaimer

The code is hosted in a public GitHub repo. I find it pointless to hide that I’m faking my activity for a couple of reasons:

  • A company that picks its candidates based on how many commits they made last year is not a company I want to work with.
  • People who look at number of commits you made last year usually don’t even check your public repositories.
  • Technical people know that this can be easily faked, and I’d rather win these people over with honesty.

I hope that this article will serve as an extra drop of doubt that eventually causes recruiters and hiring managers to stop paying attention to pointless metrics like GitHub activity. But until that day comes, you can use this method and stay ahead of the curve.