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

前端 未结 10 1625
温柔的废话
温柔的废话 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:50

    As mentioned in comments above this should be the best solution:

    $ git ls-remote | head -1 | cut -f 1

提交回复
热议问题