让我们说我有一个看起来像这样的git repo.
foo/
.git/
A/
... big tree here
B/
... big tree here
Run Code Online (Sandbox Code Playgroud)
有没有办法让git log只显示特定目录的日志消息.例如,我想查看提交仅在foo/A中触摸文件的内容?
GoZ*_*ner 217
从目录中foo/
,使用
git log -- A
Run Code Online (Sandbox Code Playgroud)
你需要' - ' <path>..
与<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
Run Code Online (Sandbox Code Playgroud)
小智 20
输入
git log .
从特定目录,它还提供该目录中的提交.
其他答案仅显示更改的文件。
git log -p DIR
如果您需要特定子目录中所有已更改文件的完整差异,则非常有用。
示例:显示特定版本范围内的所有详细更改
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
Run Code Online (Sandbox Code Playgroud)
为了跟踪文件夹移动到的文件夹的更改,我开始使用:
git rev-list --all --pretty=oneline -- "*/foo/subfoo/*"
Run Code Online (Sandbox Code Playgroud)
这并不完美,因为它会抓取具有相同名称的其他文件夹,但如果它是唯一的,那么它似乎可以工作。