gitgit-log

How can I limit the log to commits that affected a given path, but see *all* the changes made in those commits?


I am using git log to look at changes that affected a particular subdirectory:

git log -p <dirname>

This shows me commits that affect this directory, but any other changes in the same commit are not shown. I want to see them: They are things like related top-level Makefile fixes.

At the moment I am copying the commit hash for interesting commits by hand, and looking at that commit separately to see all the changes. How can I get git log to show all the changes in the limited set of commits I'm interested in?


Solution

  • Run

    git log -p `git rev-list HEAD -- <path>`
    

    where <path> corresponds to the file/directory of interest (thanks to torek).

    Basically,

    git rev-list HEAD -- <path>
    

    produces a list of revisions that affected <path>, which you then pass this list to git log -p via command substitution.