How to get the parents of a merge commit in git? 父结点
How to get the parents of a merge commit in git?
git rev-list --parents -n 1 uk-6
45ec1aaab4714f7b47136e1e43744a70fc11a9f0 【the id of current commit】
f49cddd09d099ed3a04fe608c2b4fc3e159fbb47
025a7525fabb4274800248fba55f4355aa1698db
git cat-file -p uk-6【单个父结点也可以】
tree 38c38d0bbdff0f8ac368290299b9233b929bd8e1 [the tree of current commit 不是当前结点的commit]
parent f49cddd09d099ed3a04fe608c2b4fc3e159fbb47
parent 025a7525fabb4274800248fba55f4355aa1698db
author Chuck Lu <chuck.lu@qq.com> 1584949065 +0800
committer Chuck Lu <chuck.lu@qq.com> 1584949065 +0800
Merge branch 'dev-next' into uk-6
How to find the last commit on a base branch before a merge (with a different branch) occurred?
irst there is a visual way which shows the parent commits. This might help to understand and make sure you get the right commit:
git show [commit]
(and git log
too) will print information about your merge commit in this form:
commit [commit]
Merge: [parent1] [parent2]
Author: [author]
Date: Tue Jul 19 12:00:00 2016
$ git show 8086e3
commit 8086e32d0769a0c33859b23bf01c565ac8922db3 (bruce-merge)
Merge: a183a8246 794e7864a
以测试库为例https://github.com/ChuckGitMerge/nofastforward,parent1这个commit是指master在合并之前的指向。