Find all commits related to a specific file path

git log --follow --name-only -p <file>

Every now and then a bug is introduced with a new file added to the repo. How do we track down when this file was first committed and any additional commits to this file along the way? There are many, many ways of doing this in git. One of those ways is to use git log --follow:

git log --follow --name-only -p <file>
  • git log: is the command to view the history of the entire repo
  • --follow: allows us to "follow" the commit history of a specific file including where a file was renamed
  • --name-only: allows us to trim the commit message output to only view the file names and metadata associated with the commit message rather than the complete diff
  • -p: indicates the file path to search for

Using freeCodeCamp Open Source project gives us the following when searching for the Hall Of Fame ( file.

git log lists commits in reverse chronological order: (newest first)

Here you can see the file:

  • created Feb 6, 2020
  • updated on Feb 8, 2020
  • updated again on Mar 18, 2020.
// using a relative path of the root folder freeCodeCamp to find

$ git log --follow --name-only -p './'

commit 7613df56e1736ae6c53fac3eaedc3570cdb636a9
Author: mrugesh <>
Date:   Wed Mar 18 06:23:56 2020 +0530

    chore: add Peter-Samir to HOF (#38384)

    Co-authored-by: Peter-Samir <>

commit 9e1bac4807d0268c561bb8ddad84fffac8ee07e1
Author: mrugesh <>
Date:   Sat Feb 8 21:12:19 2020 +0530

    docs: update hall of fame verbiage

commit 158188924b9281f2afe5332c7804ddcd058137c9
Author: Mehul Mohan <>
Date:   Thu Feb 6 18:14:20 2020 +0530

    docs: added responsible disclosure and hall of fame