git log --grep 搜索提交注释

来源:互联网 发布:阿里旺旺for mac 10.9 编辑:程序博客网 时间:2024/06/06 13:38

git log 支持正则表达式搜索提交消息( commit message )。

git log --grep <regexp>    --basic-regexp    -E, --extended-regexp

git log 支持 POSIX Basic Regular Expression (BRE) 和 POSIX Extended Regular Expression (ERE) ,与 grep 和 egrep 功能相同。默认使用 BRE ,如果要使用 ERE ,需要添加 -E--extended-regexp 选项。

POSIX Basic Regular Expression 简介

符号 含义 . 匹配任意单个字符(不包括\n) ^ 匹配行首 $ 匹配行尾 [ ] 匹配中括号内的单个字符 [^ ] 匹配非中括号内的单个字符 * 星号之前的字符出现0次或多次 \{n\} 前一个字符刚好出现n次 \{n,\} 前一个字符至少出现n次 \{n,m\} 前一个字符至少出现n次,至多出现m次

git log –grep 使用示例

git commit --allow-empty -m "APPLE"git log --grep 'APPLE'git log --grep 'A.*E'git log --grep '^APPLE$'git log --grep 'A[PL]*E'git log --grep 'AP\{1,2\}LE'git log --grep 'APPLE'

参考

Regular Expressions/POSIX Basic Regular Expressions

git-log

原创粉丝点击