无需克隆即可从远程回购获取最后一次提交散列 [英] Getting the last commit hash from a remote repo without cloning

查看:98
本文介绍了无需克隆即可从远程回购获取最后一次提交散列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在不克隆它的情况下获得发生在远程仓库中的最后一次提交的散列。有没有办法做到这一点 ?我发现了几种方法,但是为了所有这些方法的工作,我需要首先克隆回购,然后发出命令以获取最后一个提交哈希。



有没有办法我可以在不克隆它的情况下从远程git获得最后一次提交散列吗?



注意:

解决方案

$ git ls-remote https://github.com/gturri/dokuJClient.git
2fb540fc8c7e9116791638393370a2fa0f079737 HEAD
2fb540fc8c7e9116791638393370a2fa0f079737 refs / heads / master

这个命令可以从任何目录运行。



如果您只想要最后一个sha1,例如在脚本中使用它,您可以这样做:

  git ls -remote https://github.com/gturri/dokuJClient.git | grep HEAD | awk'{print $ 1}'


I want to get the hash of last commit that has happened in a remote repo without cloning it. Is there a way to do this ? I found several methods but for all of them to work, I need to clone the repo first and then issue the commands to get the last commit hash.

Is there a way I can get the last commit hash from a remote git without cloning it ?

Note:

解决方案

$ git ls-remote https://github.com/gturri/dokuJClient.git 
2fb540fc8c7e9116791638393370a2fa0f079737    HEAD
2fb540fc8c7e9116791638393370a2fa0f079737    refs/heads/master

This command can be run from any directory.

If you only want the last sha1, eg to use it in a script, you could then do:

git ls-remote https://github.com/gturri/dokuJClient.git  | grep HEAD | awk '{ print $1}'

这篇关于无需克隆即可从远程回购获取最后一次提交散列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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