git log format


默認git log 出來的格式並不是特別直觀,很多時候想要更簡便的輸出更多或者更少的信息,這里列出幾個git log的format。
可以根據自己的需要定制。

git log命令可一接受一個--pretty選項,來確定輸出的格式.

比如 :

如果我們只想輸出hash.

git log --pretty=format:"%h" 

詳細 命令 :

  • %H: commit hash
  • %h: 縮短的commit hash
  • %T: tree hash
  • %t: 縮短的 tree hash
  • %P: parent hashes
  • %p: 縮短的 parent hashes
  • %an: 作者名字
  • %aN: mailmap的作者名字 (.mailmap對應,詳情參照git-shortlog(1)或者git-blame(1))
  • %ae: 作者郵箱
  • %aE: 作者郵箱 (.mailmap對應,詳情參照git-shortlog(1)或者git-blame(1))
  • %ad: 日期 (--date= 制定的格式)
  • %aD: 日期, RFC2822格式
  • %ar: 日期, 相對格式(1 day ago)
  • %at: 日期, UNIX timestamp
  • %ai: 日期, ISO 8601 格式
  • %cn: 提交者名字
  • %cN: 提交者名字 (.mailmap對應,詳情參照git-shortlog(1)或者git-blame(1))
  • %ce: 提交者 email
  • %cE: 提交者 email (.mailmap對應,詳情參照git-shortlog(1)或者git-blame(1))
  • %cd: 提交日期 (--date= 制定的格式)
  • %cD: 提交日期, RFC2822格式
  • %cr: 提交日期, 相對格式(1 day ago)
  • %ct: 提交日期, UNIX timestamp
  • %ci: 提交日期, ISO 8601 格式
  • %d: ref名稱
  • %e: encoding
  • %s: commit信息標題
  • %f: sanitized subject line, suitable for a filename
  • %b: commit信息內容
  • %N: commit notes
  • %gD: reflog selector, e.g., refs/stash@{1}
  • %gd: shortened reflog selector, e.g., stash@{1}
  • %gs: reflog subject
  • %Cred: 切換到紅色
  • %Cgreen: 切換到綠色
  • %Cblue: 切換到藍色
  • %Creset: 重設顏色
  • %C(...): 制定顏色, as described in color.branch.* config option
  • %m: left, right or boundary mark
  • %n: 換行
  • %%: a raw %
  • %x00: print a byte from a hex code
  • %w([[,[,]]]): switch line wrapping, like the -w option of git-shortlog(1)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM