Validate if commit exists

后端 未结 6 1034
走了就别回头了
走了就别回头了 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:30

    git rev-list branch-youre-interested-in | grep -q sha-youre-interested-in
    

    You can use the exit code from grep in conditionals.

    For the current branch,

     git rev-list HEAD | grep -q sha-youre-interested-in
    

提交回复
热议问题