git rev-list --all -- <pathname>

Lists commit hashes containing changes to a file.

This command lists all commits in the repository's history that modify the specified file or directory, identified by <pathname>.

The flag --all instructs git to search through all branches of the repository.

The use of -- indicates that what follows is a pathspec, ensuring that the command applies to files, even if their names might be mistaken for other git arguments. This is helpful for tracking how files change over time, who modified them, and when.

Variations of this command use flags like --since="2023-01-01" to filter commits from a certain date, or replacing --all with a specific branch name to limit the search to that branch.

Sign in to enable bookmarking, reminders, progress-tracking and more...