Git:在没有本地存储库的情况下获取有关更改的信息? [英] Git: getting info about a change without a local repository?

查看:94
本文介绍了Git:在没有本地存储库的情况下获取有关更改的信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序通过SSH远程访问git仓库,有时需要获取关于特定git提交的信息(如提交信息)。如何在不存在本地克隆库的情况下查询远程git存储库中的这种信息?解析方案

通过模拟大量的操作,git已经完成内部操作并大量手动使用git plumbing (低级别)命令。但是,如果你这样做了,你不仅需要自己做很多低级别的事情,而且你的工作效率也很低(不仅如果你再次请求信息的话)。



因此,我建议您只从存储库执行(高级别)克隆,并以此方式处理它,即使该存储库仅存在临时存储。例如,如果您只想查看最新的提交,可以通过创建 克隆(使用 - depth 选项与克隆)。


My program has remote access to a git repository over ssh, and sometimes needs to get information (like commit message) about particular git commits. How can I query a remote git repository for this kind of information, without having a local clone of the repository?

解决方案

You could probably do this, by emulating a lot of operation git already does internal and by heavy manual usage of the git plumbing (low-level) commands. However if you do that, you not only need to a lot of really low-level things yourself, you also will end up with very little efficiency in what you do (not only if you request information for a second time).

So I would suggest you to just do a (high-level) clone from the repository and work with it that way, even if that repository will only exist temporary. If you only want to look at the newest commits for example, you can easily restrict what you clone by creating a shallow clone (use the --depth option with clone).

这篇关于Git:在没有本地存储库的情况下获取有关更改的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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