我尝试使用git grep -i 'search' README.md
并且输出发现了一些我有兴趣查看的行,但是这些行没有打印出 git sha,因此我可以获得有关这些提交的更多信息。输出如下所示:
README.md:ElastiCache, ElasticSearch, and RDS setup with Terraform
我如何看到这条线的 git sha?我查看了文档,其中甚至没有包含“commit”或“sha”这个词。
没有额外的规范,git grep
只看当前的提交。
要查看其他提交(或索引),您必须为它们命名(或使用--cached
)。例如,比较:
$ git grep asdf
Documentation/rev-list-options.txt: ``asdf'', and a file `quux` exists with con
t/t5516-fetch-push.sh: test_must_fail git push >.git/bar --porcelain asdfasdfas
t/t9100-git-svn-basic.sh: echo asdf > dir &&
t/t9132-git-svn-broken-symlink.sh:asdf
t/t9132-git-svn-broken-symlink.sh:test_expect_success SYMLINKS '"bar" is a symli
t/t9132-git-svn-broken-symlink.sh: (cd x && test xasdf = x"$(git cat-file b
与:
$ git grep asdf HEAD^ HEAD~3
HEAD^:Documentation/rev-list-options.txt: ``asdf'', and a file `quux` exists wi
HEAD^:t/t5516-fetch-push.sh: test_must_fail git push >.git/bar --porcelain as
HEAD^:t/t9100-git-svn-basic.sh: echo asdf > dir &&
HEAD^:t/t9132-git-svn-broken-symlink.sh:asdf
HEAD^:t/t9132-git-svn-broken-symlink.sh:test_expect_success SYMLINKS '"bar" is a
HEAD^:t/t9132-git-svn-broken-symlink.sh: (cd x && test xasdf = x"$(git ca
HEAD~3:Documentation/rev-list-options.txt: ``asdf'', and a file `quux` exists w
HEAD~3:t/t5516-fetch-push.sh: test_must_fail git push >.git/bar --porcelain as
HEAD~3:t/t9100-git-svn-basic.sh: echo asdf > dir &&
HEAD~3:t/t9132-git-svn-broken-symlink.sh:asdf
HEAD~3:t/t9132-git-svn-broken-symlink.sh:test_expect_success SYMLINKS '"bar" is
HEAD~3:t/t9132-git-svn-broken-symlink.sh: (cd x && test xasdf = x"$(git ca
如果您列出要搜索的多棵树(或提交 ID),则结果会以您的说明符为前缀,以便您知道它们与哪一棵树一起使用。
git blame README.md | grep -i 'search'