官方文檔
參考文獻
Git log 輸出格式化
在commit記錄中搜索
git log --grep eslint # 在commit 中搜索 eslint 關鍵詞
git log --grep --oneline eslint # 在 commit 中搜索 eslint 關鍵詞, 簡化輸出信息
git log --grep eslint --author liangyuetian@outlook.com # 在commit 中搜索 eslint 關鍵詞,並且篩選提交人
git log -S eslint # 查看關鍵字是什么時候引入的,可以使用 -S 選項來顯示新增和刪除該字符串的提交。
git log -S eslint --oneline # 簡化輸出信息
git log -L :countDownDiff:date.js # 查看這個文件下,countDownDiff函數的變更記錄
在commit記錄中的文件中搜索
git grep eslint # 在 文件 中搜索關鍵詞
git grep -n eslint # -n 顯示行號
git grep --count 'pay_box' # --count 簡要的輸出,只輸出文件路徑
git grep -p 'pay_box' # -p 輸出前后字符,用來判斷這個關鍵字的類型
git 修改時間顯示
git config log.date iso-local # 2020-04-23 19:08:26 +0800
git config log.date iso-strict-local # 2020-04-23T19:04:08+08:00
git config --global log.date iso-strict-local # 全局設置
常用的log格式化
# 自己常用
git log --graph --oneline --pretty=format:"%C(yellow)%h %C(green)%cn %C(red)(%cr:%cd) %C(cyan)%s"
#完美級
git log --graph --pretty=format:'%C(yellow)%h%Creset -%C(cyan)%d%Creset %s %Cgreen(%an, %cr)' --abbrev-commit