我可以在没有本地副本的情况下在远程存储库上发出git rev-parse吗? [英] Can I issue git rev-parse on remote repository without a local copy?

查看:155
本文介绍了我可以在没有本地副本的情况下在远程存储库上发出git rev-parse吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的本​​地git存储库位于加密卷内。我希望只有当远程有新的提交时才能运行 git pull --all 。但是,我无法使用post-receive hook,如这里,因为我没有加密卷的密码。这意味着,即使挂钩将被触发,我仍然不知道装入卷的密码并拉取新的更改。所以我正在寻找一些其他的替代品,我想到的一种可能的方式是向遥控器询问最新版本的SHA,并将其与本地副本知道的最新版本SHA进行比较,如果它们匹配,则我不需要运行pull命令,如果它们不匹配,那么我需要运行git pull命令。



有没有办法可以运行 git rev -parse master 在远程存储库上?



您可以获得更多关于我的问题的背景信息 here



有两个简单的近似值:


  • 如果您可以在远程使用ssh(或其他访问器),您可以运行 git rev-parse ,甚至 git rev-list 在那里,它可以为你提供尽可能多的SHA-1。

  • 你可以使用 git ls-remote 从远程获取 SHA-1(包括 refs / heads / master )。假设你在本地有头部SHA-1,所有这些都会告诉你相同或不同。如果他们不同,你不能准确地告诉他们为什么(尽管你可能会得到足够的数据 - 如果你走本地转速)。



然而,这个问题有点奇怪:你说本地回购是在你没有密码的加密卷中。如果是这样,你怎么知道本地的和/或他们的历史?他们被记录在回购中。


My local git repository is inside encrypted volume. I would like to be able to run git pull --all only when the remote has new commits. However, I'm unable to use post-receive hook like here since I don't have the password to the encrypted volume. This means that even if the hook will be triggered I still don't know the password to mount the volume and to pull the new changes. So I'm looking for some other alternatives, one possible way I was thinking of was to ask the remote for the latest version SHA and compare it with the latest version SHA that the local copy knows, if they match I don't need to run pull command and if they don't match then I need to run the git pull command.

Is there a way I can run git rev-parse master on the remote repository?

You can get more background about my problem here

解决方案

You can't do that literally.

There are two easy approximations:

  • If you can use ssh (or some other accessor) on the remote, you can run git rev-parse and even git rev-list over there, which gets you as many SHA-1s as you want.
  • You can use git ls-remote to get the head SHA-1s from the remote (including refs/heads/master). All that will tell you is "same" or "different", assuming you have the head SHA-1s locally. If they are different, you can't tell precisely why (though you can get probably-enough if you walk the local revs).

There's something weird about the question, though: you say the local repo is in an encrypted volume to which you do not have the password. If that's so, how do you know what the local heads are, and/or their history? They're recorded inside the repo.

这篇关于我可以在没有本地副本的情况下在远程存储库上发出git rev-parse吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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