Method-1: Using Keyboard Shortcut

To filter commit history (3rd / 4th panel) by certain file or directory in LazyGit, first focus on commits/reflog panel, then use <ctrl + s> keyboard shortcut to reveal filter option; Then choose Enter path to filter by, enter the path to your file or directory, and press <Enter>.

2026-01-06T112711

Method-2: Using -f Flag to Launch

Alternatively you can also specify a path with the -f when launching lazygit: lazygit --filter="content/posts/2021"

2026-01-15T150848

Behind the Scene: git log -- <path> command

Lazygit filters commits by file path using Git’s git log -- <path> command under the hood. This restricts the commits view to only those affecting the specified file or directory. The git log -- <path> is commonly used to review changes to specific files or directories without scanning the full repository history.

Common Usage Examples:

  • Filter by Directory: compact summary with stats git log --oneline --stat -- src/ shows one-line messages and file change stats for the src directory.

  • Filter by File: the command git log -- src/index.html lists hashes, authors, dates, and messages for those commits touching src/index.html ,

  • Full diffs: git log -p -- README.md displays patch diffs for each commit modifying README.md .

Reference