Sure, you could use git blame to find the author of a given line in your git repo, but how often have you done that, only to discover that the "author" just moved a line from one file to another in a refactor? How often have you seen it point to a simple constant tweak or rename on a line, leaving its original purpose for you to waste further time tracking down? gitnarrative is the solution.
matthew@terminal:~/src/gitnarrative$ gitnarrative runner.c:25
02479963 Sun Jul 20 15:08:15 2025 -0700
Move our runner constants to another file and give them more appropriate names
Matthew Kloster <admin@matthewkloster.com> changed line and moved it to runner.c:25
int mode = 0
43a80704 Sun Jul 20 03:54:09 2025 -0700
Add some helper methods
Matthew Kloster <admin@matthewkloster.com> moved line to program.c:155
b6a58bb0 Sat Jul 12 03:59:21 2025 -0700
Implement a tool to scan our data for potential revenue opportunities
Matthew Kloster <admin@matthewkloster.com> added program.c:135
int median = 0
It shows the story of how a line evolved, with changes and moves along the way, going from most recent to least.
From the source tree, run:
go build && go install
And find it featured in whatever directory you install your Go programs to.
To use, run:
gitnarrative path/to/file.go:87
That's it. Just a path, a colon, and a line number. Nothing extra, no other arguments.
This was mostly an attempt at teaching myself Go while making a tool I wished I'd had. As such, it's minimally-featured, but I do want to build in:
- Line splits (e.g. breaking apart a dictionary definition to multiple lines in Python) and merges
- Better support for recognizing tweaked compound lines, like
forloops - More context for changes