如何将存储库历史拆分为每个提交一行?

huangapple go评论68阅读模式
英文:

how to split the repository history one line for each commit?

问题

我试图获取存储库的历史记录,但结果以单行文本返回给我。

我正在使用的命令是:

cmd = f'git log --all --grep="fixed bug"'

我想要获得的结果是:

commit 337f4f4e798ea675cd57348212857ce051e857ffAuthor: Vinod...
commit 0b5a4823a963bd898b3979de8cce67513a1f83e5Author: Lofdw Kuma...
英文:

I'm trying to have the history of a repository, but the result is returned to me on a single line of text.

The command I'm using:

 cmd = f'git log --all --grep="fixed bug"'

The result I would like to have:

commit 337f4f4e798ea675cd57348212857ce051e857ffAuthor: Vinod...
commit 0b5a4823a963bd898b3979de8cce67513a1f83e5Author: Lofdw Kuma...

答案1

得分: 0

尝试这个:

git log --pretty="Commit: %H %nAuthor: %an"
  • --pretty是你想要的格式。
  • %H是提交哈希值。
  • %an是作者姓名。
  • %n代表换行符。
  • 两者之间的所有内容都是你可以根据需要自定义的字符串。

这个优质网站包含了关于该主题的大量信息:

https://git-scm.com/docs/pretty-formats

英文:

Try this:

git log --pretty="Commit: %H %nAuthor: %an"
  • --pretty is the format you want it to have.
  • %H is the commit hash.
  • %an is the author name.
  • The %n stands for newline.
  • Everything in between is a string that you can form as you like.

This beautiful site has a lot of information about that topic:

https://git-scm.com/docs/pretty-formats

huangapple
  • 本文由 发表于 2023年2月8日 20:00:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/75385510.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定