gpt4 book ai didi

git - 如何查询 git 提交历史?

转载 作者:太空狗 更新时间:2023-10-29 14:42:34 24 4
gpt4 key购买 nike

所以也许我问问题的方式不对,但我找不到有关如何执行此操作的信息。我有一个很大的 git 仓库,在过去的两年里有很多人提交了很多东西。有没有人想出我如何查询 git 提交历史记录的方法?我是一个 SQL 专家,所以我习惯使用 SQL 来查询数据库(或者甚至是 grep 或 find 来查询我的文件系统)。

这些是我想运行的示例查询:

  • 消息包含文本“xyz”的所有提交
  • 所有消息为 LIKE '%xyz' 的提交
  • 用户 person@company.com 完成的所有提交
  • 作为提交 1234abcd 的子项的所有提交
  • 日期 1 和日期 2 之间的所有提交
  • 和/或以上的组合

如果我什至可以导出 git 日志,那么我可以使用不同的工具来获取大部分信息(尽管祖先查询/分支查询可能很困难)。有时只转到命令行并快速查询以尝试查找前一段时间的提交会很好。

最佳答案

git-log docs 所述,您可以将 git log 与各种开关一起使用例如:

消息包含文本“xyz”的所有提交将是:

git log --grep=xyz

--grep=<pattern> Limit the commits output to ones with log message that matches the specified pattern (regular expression). With more than one --grep=<pattern>, commits whose message matches any of the given patterns are chosen (but see --all-match).

用户 person@company.com 完成的所有提交将是:

git log --author=person@company.com

--author=<pattern> --committer=<pattern> Limit the commits output to ones with author/committer header lines that match the specified pattern (regular expression). With more than one --author=<pattern>, commits whose author matches any of the given patterns are chosen (similarly for multiple --committer=<pattern>).

等等基于git-log docs .

关于git - 如何查询 git 提交历史?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49392457/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com