I want to get the last commit ID of the remote git repo.
The command git rev-parse HEAD
works for a locally-cloned git repo, but I want
I think what you want is this:
git ls-remote $URL HEAD
If HEAD
doesn't exist in the remote repository, then you likely want:
git ls-remote $URL refs/heads/master
Note that in the first instance, HEAD
is going to point to the default branch to checkout in the repository. You need to be sure that's the branch you want, or just use the second form and specify the one you want (replace refs/heads/master
with the name of the branch you want: refs/heads/BRANCH_NAME
.