Programming Productivity Reporting With Git (and PHP)

My mantra for programming productivity is this: sit down, shut up, and get to work. Then, once I am finished with a work session, I ask myself, “How often did I ship new features to users today?”

It’s how I know I am moving in the right direction.

So what does Git have to do with productivity? Well, Git logs all my commits to the main branches. And GitHub has a nice dashboard that adds all main branch commits across all projects.

The dashboard is how I answer the core question, “How often did I ship new features to users today?” The powerful thing about this metric is that it shows your commits to main across all repos – private and public.

I have hosted my git repos on my own servers for the last few years but added GitHub as a remote in Q4 2023 to experiment with its features. Ultimately, though, GitHub ended up becoming my “daily productivity” tracker and nothing more. The dashboard was all I used.

Not a very good use of GitHub. And certainly not enough to warrant a full migration from my private servers.

Incidentally, my normal process for Git is to host it on a VPS I own. If you are interested in how to do that, see the pro git page here.

The Script

To get the same information GitHub’s dashboard was giving me, I created a script that reports on my main branch commits per day, just like the GitHub dashboard.

Before you ask… yes, this script is written in PHP. Admittedly, I am currently going through an “if I can do it in PHP, I will…” phase, but the next section shows why I used PHP.

Add the git-report.php to your PATH as an executable, navigate to your repo location and use this command:

>$  ./git-report -d 3
2024-1-6 - 6
2024-1-5 - 10
2024-1-4 - 4

This will show you the last three days of commits. Each date has a number indicating the commits to main.

PHP and Productivity

If I have to do anything remotely complicated with scripting, like creating control structures or loops, I use PHP instead of Bash. I also know PHP better than Perl these days, so it fits.

But what does all this have to do with productivity?

One of the biggest enemies of productivity is context switching.

Context switching involves constantly changing the way we accomplish an outcome (the keyword is constantly; some change is good, but most of the time, it’s just shiny-object syndrome).

I am working on a non-trivial PHP application as I write this, so using PHP lets me avoid context switching and keeps me in the same mode of thinking, maximizing my productivity.

But GitHub has other benefits…?

You might be thinking that GitHub has a lot of other benefits. Things like visualizing your repo, GitHub actions, etc. And you are correct. These features are useful. But most of them can be achieved with scripts.

Visualizing Git Repos

I like to visualize my projects with Git’s built-in gitweb.

Navigate to your repo and use git instaweb --httpd=webrick.

Gitweb is a per-project visualizer. For multi-project visualization, use Stagit

Everything else

Almost any other action with GitHub can alternatively be achieved with Git Hooks

Bye for now.