Getting the last commit hash from a remote repo without cloning

前端 未结 2 1421
难免孤独
难免孤独 2020-12-30 05:18

I want to get the hash of last commit that has happened in a remote repo without cloning it. Is there a way to do this ? I found several methods but for all of them to work,

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-30 05:59

    $ git ls-remote https://github.com/gturri/dokuJClient.git 
    2fb540fc8c7e9116791638393370a2fa0f079737    HEAD
    2fb540fc8c7e9116791638393370a2fa0f079737    refs/heads/master
    

    This command can be run from any directory.

    If you only want the last sha1, eg to use it in a script, you could then do:

    git ls-remote https://github.com/gturri/dokuJClient.git HEAD | awk '{ print $1}'
    

提交回复
热议问题