Recently I needed to track down when a particular piece of logic changed in a file. I couldn't remember the date that it changed or any relevant information that might help me find the commit in which it changed. Luckily, git (and GitHub) provide tooling that helped me find what I was looking for.

Using Git

Git itself provides functionality to chronologically view commits that have occurred on a particular file or directory.

git log --follow -p -- pathToFileOrDirectory

# examples
git log --follow -p -- src/helpers
git log --follow -p -- src/helpers/helper1.js

If you prefer a GUI utility, you can also use gitk to accomplish the same thing:

gitk pathToFileOrDirectory

Using GitHub

If you happen to host your code on GitHub, you can also view the commits on a file or directory over time in their web interface.

Navigate to where the PATH_TO_FILE_OR_DIRECTORY is optional.