简体   繁体   中英

Using tilde or caret with 'git ls-remote'

I'm using git ls-remote to get commit hashes of branches in a repository of which I don't have a clone.

git ls-remote ssh://gitosis@myServer/myRepo.git master

I'm interested being about specify a commit like master~ and use git ls-remote to figure out what it's commit hash is.

Does Git support this?

Does Git support this?

No, as I explained in " Show git logs for range of commits on remote server? "

it works on ref patterns (head, tags, branches, ...), not with revs

You would need to fetch first, in order to check origin/master~ .


Intended use :

A custom, perhaps hackish, application.
It's a mechanism for users to issue requests to the system for building and installing specific versions of software.
It supports build_request SomeProject someBranch .
For completeness, I think it should support a request for someBranch~ .

I suppose it would be possible then to set up a kind of web service, a listener able to interpret a user query and do the git log master~ on that common server.
That listener wouldn't have anything to do with git.

If your repository is hosted by Github a partial solution consists in using the REST API. It'd be possible to adjust the results by specifying values for sha , per_page and page parameters. The general pattern is

https://api.github.com/repos/USER/REPOSITORY/commits?per_page=NUMBER&sha=SHA_OR_NAME&page=NUMBER

... eg SHA of commits in develop..develop~20 range of simelo/skycoin-hardware-wallet repository can be retrieved from the URL https://api.github.com/repos/skycoin/hardware-wallet/commits?per_page=20&sha=develop ...

... whereas SHA of commits in develop~15..develop~40 range of simelo/skycoin-hardware-wallet repository can be retrieved from this URL https://api.github.com/repos/skycoin/hardware-wallet/commits?per_page=15&sha=develop&page=2 followed by data extracted from this one https://api.github.com/repos/skycoin/hardware-wallet/commits?per_page=10&sha=develop&page=3

For further instructions about how to get this done from the command line please consult this question .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM