Code archeology with git blame

Jackson
2 min readSep 1, 2018

One of the best skills to pickup as a developer is using git blame to dig through previous commits of code. I don’t just mean finding the original author of a line of code, but also leveraging the power of git blame to look back in time for answers.

These are just a few of the ways that this skill can help you:

  1. Answer questions about an old piece of code. This is sometimes better than just pinging the original developer. The original developer may not be at the company anymore, or it’s been so long that they forgot what they wrote! Using git blame, you find the original pull request which will hopefully have enough information to give you an answer.
  2. Find guidance on how to use a specific pattern. There are times you think “there has got to be a better way to do this!” and look around the codebase for an existing pattern to solve your problem. You stumble across a piece of code that looks like it should work…but when you try to copy it to the code that you’re working on, it just doesn’t. It may be that there is a piece that you are missing. Git blame is great to help you find the original commit and pull request that implemented that pattern along with all the pieces that make it work.
  3. Expand your context. A great way to become a better developer is to read code — a lot. Encounter a piece of code that makes you excited? Git blame and find the pull request to read the patch in its entirety. Wonder about how your company processes payments and why it’s done that way? Git blame to the pull request(s) to find all the work that went into that feature.

This superpower has not only sped up my context gathering phase when working on a problem, but also allowed me to learn from the best.

I end with the PSA below.

PSA: Please learn to use this feature in Github to travel back in time. This is a very powerful feature and is absolutely critical to unlocking all the productivity mentioned above.

--

--