How to get SHA of the latest commit from remote git repository?

前端 未结 10 1626
温柔的废话
温柔的废话 2020-12-04 13:58

Does anyone know how to get the latest SHA of a given branch from outside a git repository?

If you are inside a git repository, you can do:

10条回答
  •  生来不讨喜
    2020-12-04 14:47

    This should do the trick git ls-remote REMOTE | awk "/BRANCH/ {print \$1}"

    Replace REMOTE with the name of the remote repository and BRANCH with the name of the branch.

提交回复
热议问题