红穆笔记

git annotate

顯示文件中每一行的提交哈希值和最後修改作者。 參見 `git blame`(推薦優先使用該命令)。 提供`git annotate` 主要是爲了照顧熟悉其他版本控制系統的用戶

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

常用示例

打印文件內容,並在每行前附加作者姓名和提交哈希值

git annotate {{路徑/到/文件}}

打印文件內容,並在每行前附加作者郵箱和提交哈希值

git annotate {{[-e|--show-email]}} {{路徑/到/文件}}

僅打印匹配正則表達式的行

git annotate -L :{{正則表達式}} {{路徑/到/文件}}

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

英文原文對照

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

Show commit hash and last author on each line of a file. See `git blame`, which is preferred over `git annotate`. `git annotate` is provided for those familiar with other version control systems. More information

Print a file with the author name and commit hash prepended to each line

git annotate {{path/to/file}}

Print a file with the author email and commit hash prepended to each line

git annotate {{[-e|--show-email]}} {{path/to/file}}

Print only rows that match a `regex`

git annotate -L :{{regex}} {{path/to/file}}

命令信息

命令名git annotate
用途顯示文件中每一行的提交哈希值和最後修改作者。 參見 `git blame`(推薦優先使用該命令)。 提供`git annotate` 主要是爲了照顧熟悉其他版本控制系統的用戶
適用平臺通用
示例數量3 條
官方文檔https://git-scm.com/docs/git-annotate
數據來源tldr-pages(CC-BY-4.0)· 社區中文翻譯

常見問題

git annotate 命令是做什麼的?

顯示文件中每一行的提交哈希值和最後修改作者。 參見 `git blame`(推薦優先使用該命令)。 提供`git annotate` 主要是爲了照顧熟悉其他版本控制系統的用戶

git annotate 怎麼用?

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

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

打印文件內容,並在每行前附加作者姓名和提交哈希值:git annotate {{路徑/到/文件}}

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

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