How to get parent of specific commit in Git?

前端 未结 8 1222
别跟我提以往
别跟我提以往 2021-02-02 06:25

I have commit number. I would like to get previous commit number(parent). I need commits from current branch.

8条回答
  •  粉色の甜心
    2021-02-02 06:54

    If ${SHA} is the commit you know and you want its parent (assuming it's not a merge commit and has only one parent):

    git rev-parse ${SHA}^
    

提交回复
热议问题