Reputation: 62772
Let’s say that I have a Git repository that looks like this:
foo/
.git/
A/
... big tree here
B/
... big tree here
Is there a way to ask git log
to show only the log messages for a specific directory? For example, I want to see what commits touched files in foo/A
only.
Upvotes: 362
Views: 234675
Reputation: 70235
For directory foo/
, use
git log -- foo
You need the '--' to separate <path>..
from the <since>..<until>
refspecs.
# Show changes for src/nvfs
$ git log --oneline -- src/nvfs
d6f6b3b Changes for Mac OS X
803fcc3 Initial Commit
# Show all changes (one additional commit besides in src/nvfs).
$ git log --oneline
d6f6b3b Changes for Mac OS X
96cbb79 gitignore
803fcc3 Initial Commit
Upvotes: 394
Reputation: 885
Enter
git log .
from the specific directory. It also gives commits in that directory.
Upvotes: 86
Reputation: 14950
The other answers only show the changed files.
git log -p DIR
is very useful, if you need the full diff of all changed files in a specific subdirectory.
Example: Show all detailed changes in a specific version range
git log -p 8a5fb..HEAD -- A B
commit 62ad8c5d
Author: Scott Tiger
Date: Mon Nov 27 14:25:29 2017 +0100
My comment
...
@@ -216,6 +216,10 @@ public class MyClass {
+ Added
- Deleted
Upvotes: 8
Reputation: 2672
For tracking changes to a folder where the folder was moved, I started using:
git rev-list --all --pretty=oneline -- "*/foo/subfoo/*"
This isn't perfect as it will grab other folders with the same name, but if it is unique, then it seems to work.
Upvotes: 7
Reputation: 29261
You can use git log
with the pathnames of the respective folders:
git log A B
The log will only show commits made in A
and B
. I usually throw in --stat
to make things a little prettier, which helps for quick commit reviews.
Upvotes: 29