用于搜索提交消息的Git别名

问题描述 投票:3回答:3

我确实在网上找到别名:

find = "log --decorate -i --all --date=short --grep"

search = "!f() { git log --decorate --grep=$1 -i --all --date=short; }; f"

它们都做同样的事情:在提交消息中搜索。有一个以某种方式比另一种“优越”吗?为什么?

问题-我们如何编写别名来搜索消息中包含特定单词的提交?

例如,在哪里:

git search-msg foo bar baz

匹配提交包含单词foobarbaz,以哪种顺序排列?

git search alias message commit
3个回答
1
投票

您可能想要添加历史记录以通过在rev-list中添加git log来搜索整个存储库。>

git log --grep 'Something relevant in my commits' $(git rev-list --all)

类似的东西应该在。gitconfig

文件中工作
[alias]
    search = "!f() { git log --grep \"$1\" $(git rev-list --all); }; f"
[log]
    date = iso

date = iso这是为了得到更好的日期(当前格式为2019-11-26 17:35:30 +0100


0
投票

通常,将git命令与匿名bash函数一起使用可让我们访问其他功能。


0
投票

首先介绍git log的--grep option

© www.soinside.com 2019 - 2024. All rights reserved.