Validate if commit exists

后端 未结 6 1038
走了就别回头了
走了就别回头了 2020-12-10 02:45

How to validate whether the commit with given sha exists in current branch?

There are many ways to parse outputs, but I need optimal way which returns boolean (for u

6条回答
  •  旧巷少年郎
    2020-12-10 03:17

    git cat-file prints information about the objects in the repository. "-e" checks if the object is valid and exits with a 0 status and when invalid exists with a 1.

    git cat-file -e 3d68db1028afe27a0055c2234f98fc945b1958f5
    echo $?
    1
    

提交回复
热议问题