How to get the last commit ID of a remote repo using curl-like command?

前端 未结 6 838
我寻月下人不归
我寻月下人不归 2020-12-12 19:38

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

6条回答
  •  囚心锁ツ
    2020-12-12 20:00

    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.

提交回复
热议问题