You are not logged in.
Is it possible to use git to retrieve the number of commits from a purely remote repo?
For example, I can grab the last commit hash to a purely remote repo this way:
% git ls-remote -h https://github.com/torvalds/linux
358feceebbf68f33c44c6650d14455389e65282d refs/heads/masterI want to see the number of commits in a like fashion. For example:
% git COMMAND ... https://github.com/torvalds/linux
984,205Last edited by graysky (2021-02-14 14:09:21)
Offline
Not really, though if you have ssh interactive shell access on the remote you could run git describe remotely.
What's the purpose of this?
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
I want to have a script pull the latest commit hash (which I can via piping the output above into awk) and also the total number of commits remotely. I too do not think it is possible.
Offline
That's not the purpose of this, that's the mechanism you intend to use in the course of achieving your purpose.
This xyproblem thing is always pretty annoying.
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
I ended up hacking a grep/head/sed solution together but it's ugly.
URL='https://github.com/graysky2/xbmc'
BRANCH=gs-gbm_nexus
newcommit=$(git ls-remote -h "$URL" "$BRANCH" | awk '{print $1}')
newcount=$(curl -v --stderr - "$URL"/tree/"$BRANCH" | grep -B 1 "Commits on $BRANCH" | head -n1 | sed -e s'/^.*<strong>//' -e 's/<\/strong>//' -e 's/,//')
echo $newcommit
echo $newcountOffline