![](/img/trans.png)
[英]How do I import another git repository as a sub-directory with all of its history grouped at the HEAD of the commit log?
[英]How to show Git log history (i.e., all the related commits) for a sub directory of a Git repository
假設我有一個如下所示的 Git 存儲庫:
foo/
.git/
A/
... big tree here
B/
... big tree here
有沒有辦法讓git log
只顯示特定目錄的日志消息? 例如,我只想查看哪些提交觸及了foo/A 中的文件。
從目錄foo/
,使用
git log -- A
您需要使用“--”將<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
進入
git log .
從特定目錄。 它還提供該目錄中的提交。
您可以將git log
與相應文件夾的路徑名一起使用:
git log AB
日志將只顯示在A
和B
提交。 我通常會加入--stat
來讓事情變得更漂亮,這有助於快速提交審查。
其他答案僅顯示更改的文件。
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
為了跟蹤移動文件夾的文件夾的更改,我開始使用:
git rev-list --all --pretty=oneline -- "*/foo/subfoo/*"
這並不完美,因為它會抓取具有相同名稱的其他文件夾,但如果它是唯一的,那么它似乎可以工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.