在git上获取最新版本的日期

时间:2014-08-12 16:32:12

标签: php git version-control

我想在git上获取项目的最后版本日期...意味着项目的最后一次更改日期:

我不熟悉git,经过多次搜索后我尝试了这个:

$ git --version
git version 1.8.1.2    
$ git log -1 --format="%ct" http://selenium.googlecode.com/git/
fatal: Not a git repository (or any of the parent directories): .git

代码是通过exec()从php执行的,并且返回的日期将在以后格式化......

2 个答案:

答案 0 :(得分:1)

git无法连接到服务器并检查其日志。您需要克隆存储库并使用git log -1 --format="%ci"获取日期或使用主机提供的API,Github有一个API不确定谷歌代码,但您可以解析该网站以获取信息。

答案 1 :(得分:0)

这将显示每个分支上的最新提交,因此列表中的第一个是整个项目的最新提交:

git for-each-ref --sort=-committerdate refs/heads/ --format="%(authordate) %(refname)"

您可以使用PHP来处理输出。