从特定分支列出Git提交SHA,而不克隆存储库 [英] List Git commit SHAs from a specific branch without cloning the repository

查看:72
本文介绍了从特定分支列出Git提交SHA,而不克隆存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不克隆存储库或不使用API​​的情况下获取特定分支的所有提交ID?

Is there a way to get all the commit IDs for a particular branch without cloning the repository or using the API's?

我正在寻找类似的东西.不幸的是,以下命令仅在存储库(即git目录)中有效.我希望能够在不克隆仓库的情况下做到这一点.

I'm looking for something like this. Unfortunately the below command works only within the repository (i.e., git directory). I want to able to do it without cloning the repo.

git rev-list --remotes=*master 

例如,下面的命令使所有分支和它的最后提交ID(注意:该命令起作用,而无需克隆回购)

For example, the below command brings all the branches and it's last commit ID (Note: the command works without having to clone the repo.)

git ls-remote -h http://user:password@example.gitlab.com/ProjectA/example.git 

示例输出:

82cd0dcc9d1005b44bdc799034b706f9ad2b1e0e    refs/heads/master
afacc961fedf49a84c09ab91e67633b02921dd07    refs/heads/projects/myproject
b6d954ec86750dcfd35c1c3fba4f40449abeb6ed    refs/heads/releases/production
e891a0b29847d0d7dfc5bc7e5ad45f718918f67f    refs/heads/releases/ready_for_prod
7b0282004a6f72c5803ddf19172c16a0b3124038    refs/heads/releases/test

推荐答案

使用常规Git命令是不可能的,但是您已经用

  • GitHub : GET/repos/:owner/:repo/commits 并提供参数 sha ,其中包含要列出其提交的分支的名称
  • GitLab : GET/项目/:ID/库/提交,然后提供一个参数的 ref_name 的包含其提交你希望清单分支的名称
  • GitHub: GET /repos/:owner/:repo/commits and provide a parameter sha containing the name of the branch whose commits you wish to list
  • GitLab: GET /projects/:id/repository/commits and provide a parameter ref_name containing the name of the branch whose commits you wish to list

您可能需要使用GitLab企业版才能使用其API.(在GitLab.com上托管的版本应支持它.)

You may need to be using GitLab Enterprise Edition to use its API. (The version hosted at GitLab.com should support it.)

这篇关于从特定分支列出Git提交SHA,而不克隆存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆