红穆笔记

git log

查看提交歷史

100% 瀏覽器本地處理 0 數據上傳

常用示例

按時間先後順序列出當前倉庫所有的提交,最近的更新排在最上面

git log

查看指定文件或指定目錄的歷史,包括每次提交所引入的差異

git log {{[-p|--patch]}} {{路徑/到/文件或目錄}}

顯示每次提交的文件修改統計信息

git log --stat

在日誌旁以 ASCII 圖形顯示當前分支提交歷史,並只展示提交消息的第一行

git log --oneline --graph

在日誌旁以 ASCII 圖形顯示整個倉庫的所有提交、標籤、分支

git log --oneline --decorate --all --graph

查看提交消息中包含特定字符串(大小寫敏感)的提交

git log {{[-i|--regexp-ignore-case]}} --grep {{字符串}}

查看特定作者的最近 N 條提交

git log {{[-n|--max-count]}} {{數字}} --author "{{作者}}"

查看兩個日期之間的提交(yyyy-mm-dd)

git log --before "{{2017-01-29}}" --after "{{2017-01-17}}"

提示:花括號{{…}}是需要替換的參數(路徑、文件名等);命令只在本機終端執行,本站不保存任何輸入。

英文原文對照

展開英文說明與示例(來源 tldr-pages)

Show a history of commits. More information

Show the sequence of commits starting from the current one, in reverse chronological order of the Git repository in the current working directory

git log

Show the history of a particular file or directory, including differences

git log {{[-p|--patch]}} {{path/to/file_or_directory}}

Show an overview of which file(s) changed in each commit

git log --stat

Show a graph of commits in the current branch using only the first line of each commit message

git log --oneline --graph

Show a graph of all commits, tags, and branches in the entire repo

git log --oneline --decorate --all --graph

Show only commits with messages that include a specific string, ignoring case

git log {{[-i|--regexp-ignore-case]}} --grep {{search_string}}

Show the last `n` number of commits from a certain author

git log {{[-n|--max-count]}} {{n}} --author "{{author}}"

Show commits between two dates (yyyy-mm-dd)

git log --before "{{2017-01-29}}" --after "{{2017-01-17}}"

命令信息

命令名git log
用途查看提交歷史
適用平臺通用
示例數量8 條
官方文檔https://git-scm.com/docs/git-log
數據來源tldr-pages(CC-BY-4.0)· 社區中文翻譯

常見問題

git log 命令是做什麼的?

查看提交歷史

git log 怎麼用?

頁面按場景列出了8 條常用示例:每條示例先說明用途,再給出可直接複製的完整命令(花括號裏是需要替換的參數)。

git log 最常用的操作是什麼?

按時間先後順序列出當前倉庫所有的提交,最近的更新排在最上面:git log

命令裏的花括號是什麼意思?

花括號{{…}}表示需要替換成你自己的值,例如路徑、文件名;同名參數方括號(如 [-C|--directory])表示可選寫法。