Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何打印所有git提交消息?_Git_Jgit - Fatal编程技术网

如何打印所有git提交消息?

如何打印所有git提交消息?,git,jgit,Git,Jgit,我有一个git存储库,我可以使用git日志分支名称查看特定分支中的所有提交。但是我想在HTML页面上打印关于特定分支的所有提交的提交消息、作者和日期。有什么解决办法吗? 我如何使用jgit来实现这一点?我不知道jgit,但在普通git中,您可以使用pretty选项 git log --pretty=oneline commit1...commit2 > file git log --pretty="%ci %an %s" branch-name 其中,%ci是日期(ISO),%an是提

我有一个git存储库,我可以使用
git日志分支名称查看特定分支中的所有提交。但是我想在HTML页面上打印关于特定分支的所有提交的提交消息、作者和日期。有什么解决办法吗?


我如何使用
jgit
来实现这一点?

我不知道
jgit
,但在普通git中,您可以使用
pretty
选项

git log --pretty=oneline commit1...commit2 > file
git log --pretty="%ci %an %s" branch-name
其中,
%ci
是日期(ISO),
%an
是提交人,
%s
是主题

编辑


您可以在日志文档的pretty format部分找到更多信息:

您需要遍历分支上的每个提交,并用适当的html标记包装输出。现在我知道你想从jgit开始做这件事,所以我将提供一个如何在shell中做这件事的概要,你必须同样调用jgit‡;的
rev list
功能:

#/垃圾箱/垃圾箱
回声“”
对于以美元表示的提交(git版本列表);做
git日志--format=“%cr%an%s”$commit
完成
回声“”
有关不同格式选项,请访问帮助页


‡;我还没有真正检查过jgit是否支持rev list,但据我所知,在上的声明是它支持git核心功能。例如,请参阅

#!/bin/sh

echo "<table style=\"width:300px\">"
for commit in $(git rev-list <your branch>); do
  git log --format="<tr><td>%cr</td><td>%an</td><td>%s</td></tr>" $commit
done
echo "</table>"