Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I issue git rev-parse on remote repository without a local copy?

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

like image 583
e271p314 Avatar asked Oct 20 '22 22:10

e271p314


1 Answers

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.

like image 149
torek Avatar answered Oct 30 '22 02:10

torek