无需克隆即可从远程回购获取最后一次提交散列

编程入门 行业动态 更新时间:2024-10-24 22:24:32
本文介绍了无需克隆即可从远程回购获取最后一次提交散列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

注意:

解决方案

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

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

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

git ls -remote github/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 github/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 github/gturri/dokuJClient.git | grep HEAD | awk '{ print $1}'

更多推荐

无需克隆即可从远程回购获取最后一次提交散列

本文发布于:2023-11-28 22:43:53,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!