SWHarden.com

The personal website of Scott W Harden

Merge External Repositories into GitHub Contribution Graph

How I import anonymized commits from untracked repositories to keep my green squares current

I enjoy gazing at the green squares in my GitHub Contribution Graph as a way to visualize the ebbs and flows of my development efforts over the last decade. However, I’ve been working more in repositories on other platforms (GitLab, Azure, and locally) which are not tracked by GitHub and do not contribute to their activity graph. I sought a solution to reclaim those hard-earned green squares!

This page documents how I created an anonymized git activity aggregator that integrates commits across various untracked git repositories into a single private repo that can be used to accurately reflect my total development effort as green squares on GitHub’s Contribution Graph.

Results

Before Merge: There is a sharp decrease in commits in April when I started committing to untracked repositories.

After Merge: Activity continues through April, and the high effort near the end of the year is visible.

Implementation Overview

The code itself isn’t too complex, leaned heavily on the libgit2sharp .NET package, and its source code is available so I’ll describe what it does at a high level:

Future Directions

This strategy could be extended to provide extensive analytics for multiple users working across large multi-project code bases. Although the present implementation aimed to preserve anonymity of the analyzed source code, extending commit analysis records to include repository name, commit messages, and author details could facilitate generation of fascinating reports where users can be seen working across different projects at different times. Consider what an activity graph would look like for a single user if each square were colored according to the repo they were working in, or a graph that shows a single repo with different authors represented by different squares. The simplicity of the git analysis methods described here make graphs like these feasible to realize without much additional effort.

Additional Resources