git-常用的搜索命令

官方文档

参考文献

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

原文地址:https://www.cnblogs.com/daowangzhizhu-pt/p/12778478.html