简体   繁体   English

无需克隆即可获取Github存储库的最新git commit哈希

[英]Retrieve latest git commit hash of a Github repository without cloning

Is it possible to remotely retrieve the latest commit hash of a Github repo without cloning it locally? 是否可以远程检索Github存储库的最新提交哈希,而无需在本地克隆它? I'm referring to something like the following you see at the top of all the repos in Github: 我指的是类似下面在Github中所有回购顶部看到的内容:

Github最新提交

Based on some older questions it seems that this may not be possible with git directly (unless there's a new feature that enables it), so the right answer might involve using the Github API (turns out Github API won't work for my use case since I'll have to use a different set of credentials then the private key git uses). 基于一些较旧的问题 ,似乎直接使用git可能无法实现(除非有启用它的新功能), 因此正确的答案可能涉及使用Github API (事实证明Github API在我的用例中不起作用)因为我必须使用一组不同的凭据,然后才使用私钥git )。

Found the answer here thanks to @jszakmeister: 感谢@jszakmeister 在这里找到了答案:

git ls-remote $URL HEAD

For my private repo, I had to use the following syntax instead of the URL: 对于我的私人仓库,我不得不使用以下语法而不是URL:

git ls-remote git@github.com:ORG/PROJECT.git HEAD

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 github - 获取带有特定标记的提交的git哈希,无需克隆或提取 - github - get git hash for commit with specific tag without cloning or pulling 是否可以在不首先使用 GitPython(或更一般的 Git)克隆存储库的情况下检索当前 HEAD 的提交 ID? - Is it possible to retrieve the commit ID of the current HEAD without first cloning the repository using GitPython (or more generally Git)? 将git提交到远程存储库,而无需克隆任何本地存储库 - Commit git to remote repository without cloning any local repository 如何在 Windows 中提取远程 git 存储库的最新提交哈希? - How to extract latest commit hash for a remote git repository in Windows? 列出来自特定分支的 Git 提交 SHA,而不克隆存储库 - List Git commit SHAs from a specific branch without cloning the repository 如何在不克隆的情况下从 git 存储库获取 SHA1 哈希? - How to get SHA1 hash from a git repository without cloning? 如何在GITHUB中无需克隆的情况下查找Git存储库的修订版ID - How to find revision ID of a Git repository without cloning in GITHUB 如何在没有本地git仓库的情况下提交到github仓库? - How to commit to github repository without a local git repository? 下载GitHub存储库而不克隆它? - Download GitHub repository without cloning it? 捆绑 git 存储库而不克隆它 - Bundle git repository without cloning it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM