使用gitlog时,如何按用户进行筛选,以便只看到该用户的提交?
当前回答
如果您使用IntelliJ,您可以转到
View -> Tool Windows -> Git
选择“日志”并单击“用户:全部”
然后键入作者的姓名,它将显示该作者的每一次提交
其他回答
一种可能的替代方法是使用名为mergestat的工具,该工具允许您针对repo中的提交历史运行SQL查询(除其他外)。
mergestat "SELECT * FROM commits WHERE author_name LIKE '%Jon%'"
它有点冗长,但可以提供灵活性,以通用的方式具体查找您要查找的内容。
例如,过滤掉合并提交,仅显示过去一年中特定作者的提交:
mergestat "SELECT * FROM commits WHERE author_name LIKE '%Jon%' WHERE author_when > DATE('now', '-1 year') AND parents < 2"
完整披露:我是项目的维护者:)
git log --author="that user"
如果要过滤自己的提交:
git log --author="<$(git config user.email)>"
试试这个工具https://github.com/kamranahmedse/git-standup
用法
$ git standup [-a <author name>]
[-w <weekstart-weekend>]
[-m <max-dir-depth>]
[-f]
[-L]
[-d <days-ago>]
[-D <date-format>]
[-g]
[-h]
以下是每个标志的说明
- `-a` - Specify author to restrict search to (name or email)
- `-w` - Specify weekday range to limit search to (e.g. `git standup -w SUN-THU`)
- `-m` - Specify the depth of recursive directory search
- `-L` - Toggle inclusion of symbolic links in recursive directory search
- `-d` - Specify the number of days back to include
- `-D` - Specify the date format for "git log" (default: relative)
- `-h` - Display the help screen
- `-g` - Show if commit is GPG signed or not
- `-f` - Fetch the latest commits beforehand
通过在.bashrc文件中添加这个小片段,以彩色显示x用户的n个日志。
gitlog() {
if [ "$1" ] && [ "$2" ]; then
git log --pretty=format:"%h%x09 %C(cyan)%an%x09 %Creset%ad%x09 %Cgreen%s" --date-order -n "$1" --author="$2"
elif [ "$1" ]; then
git log --pretty=format:"%h%x09 %C(cyan)%an%x09 %Creset%ad%x09 %Cgreen%s" --date-order -n "$1"
else
git log --pretty=format:"%h%x09 %C(cyan)%an%x09 %Creset%ad%x09 %Cgreen%s" --date-order
fi
}
alias l=gitlog
要显示Frank的最后10次提交:
l 10弗兰克
要显示任何人的最后20次提交:
l 20
推荐文章
- 当我试图推到原点时,为什么Git告诉我“没有这样的远程‘原点’”?
- 如何从远程分支中挑选?
- 如何查看一个分支中的哪些提交不在另一个分支中?
- 如何取消在github上的拉请求?
- HEAD和master的区别
- GIT克隆在windows中跨本地文件系统回购
- RPC失败;卷度传输已关闭,剩余未完成的读取数据
- 我应该在.gitignore文件中添加Django迁移文件吗?
- 错误:您对以下文件的本地更改将被签出覆盖
- Git rebase—即使所有合并冲突都已解决,仍然会继续报错
- 在Git中,我如何知道我的当前版本是什么?
- 跟踪所有远程git分支作为本地分支
- 为什么要把Gradle Wrapper提交给VCS?
- 自定义SSH端口上的Git
- git如何显示不存在于.gitignore中的未跟踪文件