5

I've got a script that needs to quickly gather the output of 'git describe' on a specific branch of a remote git repository, in order to set an environment variable.

The obvious way to do that would be to do a 'git clone' to download the repository, then cd into the created git repository folder and do a

export GIT_DESCRIBE_STR=`git describe`

... but I don't really like that approach, because it has so much overhead; in particular, the 'git clone' command would download hundreds of megabytes of git repository data every time it runs, just to run the git describe command once; and after that the downloaded data would not be used.

My question is, is there any way to run 'git describe' on a remote repository? Something equivalent to this, which of course doesn't work because I just made it up:

git describe --repository=https://my.server.com/r/myproject/myproject.git --branch=master
Jeremy Friesner
  • 70,199
  • 15
  • 131
  • 234
  • `clone --depth 1` should reduce the overhead a bit, but it's not a particularly good solution. – Keith Thompson Oct 03 '16 at 23:57
  • Actually it's a lousy solution. If the head of the remote repo isn't tagged, there's nothing for `git describe` to show. (I just tried it with git://git.kernel.org/pub/scm/git/git.git) – Keith Thompson Oct 04 '16 at 00:04
  • I suspect not. Git intentionally does not have many commands between client and server. `fetch`, `push`, `ls-remote` are all that I'm aware of; there are probably a few more plumbing commands that I'm not. But if you use SSH with a wrapper, you should be able to roll your own custom server script. There's probably some way to do that kind of thing with HTTP, and whatever front end you have providing it. `gitolite`, for instance, allows you to write custom commands that can be accessible via both SSH and HTTP. – Mort Oct 04 '16 at 00:17
  • 1
    How about something like this: https://github.com/svnpenn/a/blob/ac63f1dd/misc/git-describe-remote.awk – Arkadiusz Drabczyk Oct 04 '16 at 07:27

0 Answers0