[英]How can I show the revision date of a remote git repository's master branch, without cloning the whole repository?
I need to know the date and time of the latest revision of the master branch on a remote repository. 我需要知道远程存储库上master分支的最新修订的日期和时间。 I've got git installed locally, and I know the HTTPS clone URL for the git repo, which is hosted on GitHub. 我已经在本地安装了git,而且我知道git repo的HTTPS克隆URL,该URL托管在GitHub上。 I know that if I had the repo cloned, I could do git show --format="%ci %cr" master | head -n 1
我知道如果克隆了仓库,我可以做git show --format="%ci %cr" master | head -n 1
git show --format="%ci %cr" master | head -n 1
, but I need a command that will run quickly, and not leave any sizeable data behind; git show --format="%ci %cr" master | head -n 1
,但是我需要一个可以快速运行的命令,并且不会留下任何可观的数据; Cloning a 200 MB repo won't work. 克隆200 MB的存储库将不起作用。
How can I show the revision date of a remote GitHub repository's master branch, without cloning the whole repository? 如何在不克隆整个存储库的情况下显示远程GitHub存储库的master分支的修订日期?
I don't think you can do this strictly with Git (ie in a way that would work with all Git remotes). 我认为您不能使用Git严格执行此操作(即,以与所有 Git遥控器均兼容的方式)。 But there is a solution using GitHub's GET /repos/:owner/:repo/branches/:branch
endpoint , eg 但是有一个使用GitHub的GET /repos/:owner/:repo/branches/:branch
端点的解决方案 ,例如
curl https://api.github.com/repos/github/git-lfs/branches/master
# {
# "name": "master",
# "commit": {
# "sha": "df4be34fff5d9c70f5d8b897bbe23fa809776b6a",
# "commit": {
# "author": {
# "name": "risk danger olson",
# "email": "technoweenie@gmail.com",
# "date": "2015-08-04T21:24:00Z"
# },
# "committer": {
# "name": "risk danger olson",
# "email": "technoweenie@gmail.com",
# "date": "2015-08-04T21:24:00Z"
# },
# ...
Use your favourite JSON library to extract the commit/commit/author/date
and / or commit/commit/committer/date
nodes from the response. 使用您喜欢的JSON库从响应中提取commit/commit/author/date
和/或commit/commit/committer/date
节点。 The command-line tool jq
might be helpful: 命令行工具jq
可能会有所帮助:
curl https://api.github.com/repos/github/git-lfs/branches/master \
| jq .commit.commit.author.date,.commit.commit.committer.date
# "2015-08-04T21:24:00Z"
# "2015-08-04T21:24:00Z"
For private repositories you'll have to authenticate . 对于私有存储库,您必须进行身份验证 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.