How to get parent of specific commit in Git?

How to get parent of specific commit in Git?

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

回答

To get Parent Commit

git cat-file -p commit_id

tree tree_id
parent parent_commit_id
[parent other_parent_commit_id] # present only in case of merge commits
author xxx <xxx@email.com> 1513768542 +0530
committer xxx <xxx@email.com> 1513768542 +0530 

 

posted @ 2021-04-22 18:05  ChuckLu  阅读(81)  评论(0)    收藏  举报