How to show a commit’s patch pertaining to a specific path?

When viewing the patch of a certain commit with git show <commit> you’re only interested in a certain part of it, related to a file or a directory.

When viewing the patch of a certain commit with git show <commit> you’re only interested in a certain part of it, related to a file or a directory. In that case instead of searching for that part of the patch you can simply append the path:

git show <commit> -- <path>

So, for example, if you wanted to see which changes were made to the files inside the directory helpers/users by the commit 72c8fbde, you would run:

git show 72c8fbde -- helpers/users

Subscribe to GIT.WTF!?!

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe