我知道如何在文件中运行 gblame。
我知道如何在目录中所有文件中搜索内容。
我想看到包含某个内容的特定行周围的 gblame。例如:
$ blame -R "content" ./
我看到一个文件列表。我想要对它们进行gblame,了解是谁修改过这些行的代码。
我知道如何在文件中运行 gblame。
我知道如何在目录中所有文件中搜索内容。
我想看到包含某个内容的特定行周围的 gblame。例如:
$ blame -R "content" ./
我看到一个文件列表。我想要对它们进行gblame,了解是谁修改过这些行的代码。
你可以使用Perl来完成它:
git grep -n 'content' | perl -F':' -anpe '$_=`git blame -L$F[1],+1 $F[0]`'
如果您想创建自定义命令,可以将类似以下内容添加到gitconfig的别名部分:
gb = "!f() { git grep -n $1 | perl -F':' -anpe '$_=`git blame -L$F[1],+1 $F[0]`'; }; f"
查找有针头的文件,对每个文件进行指责,并对每个指责输出搜索针头
for file in `grep -lr needle *`; do git blame $file |grep needle ; done
你可以使用-C参数添加上下文
for file in `grep -lr needle *`; do git blame $file |grep -C5 needle ; done
#!/bin/bash
if [ "$1" = "" ] ; then
echo "usage: $0 <term>" 1>&2
exit 1
fi
for file in $(git grep $1 | cut -d ':' -f 1 | uniq) ; do
echo $file ::
git blame $file | grep $1
done
git blame -fL$F[1],+1 $F[0]
。 - Cash Logit blame -lf $F[1],+1 $F[0] | | git name-rev --stdin --tags --always
命令来查看最接近的发布标签。 - Dan Berindei