- 顯示某個版本下的某個文件
git show sha1:file
- 遍歷某個版本的所有文件
try( TreeWalk treeWalk = new TreeWalk( repository ) ) {
treeWalk.reset( commit.getId() );
while( treeWalk.next() ) {
String path = treeWalk.getPathString();
// ...
}
}
- diff兩個版本
git diff HEAD HEAD^ --stat
- 顯示某次commit
git show commit_id
5.顯示修改某一個文件的所有commit
git log file -n
n為最多顯示的記錄條數(shù)乍钻,需要注意的是鸵荠,此命令只會顯示文件名沒有變化的條目,即如果一個文件在某次提交修改了名字,并用最終名字查詢該命令搭伤,之前命令會被自動截取
要想獲取全部歷史袄秩,請使用下面這條命令
git log --follow -- file
6.顯示一次commit所有的所有的文件名
git diff --name-only <commit-id-1> <commit-id-2>
7.顯示代碼每行添加時的commit
git blame test.txt
$ git blame test.txt
^410c3dd (Leigh 2013-11-09 12:00:00 1) First line.
2365eb7d (Leigh 2013-11-09 12:00:10 2) Second line.
- 顯示一個已被刪除文件的歷史
git log --pretty=oneline --all --full-history -- solr/core/src/test/org/apache/solr/update/AutoCommitTest.java