如何找出合并提交父母的编号? [英] How do I find out the numbering of merge commit parents?

查看:118
本文介绍了如何找出合并提交父母的编号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做一个git revert -m,但是我一直没能找到关于如何提交父母的文档。我见过的所有东西(包括rev-parse的帮助页面)都告诉我父母有数字,但没有说他们是如何编号的。有人可以指出我在哪里定义以及如何确定它? git show --format =%P< SHA>

会按照数字顺序为您提供给定提交的父SHA。大多数情况下,您要为 git revert 指定的内容将是 1



在大多数合并的情况下,检出的分支的SHA将成为第一个父分支,合并的分支的SHA将成为第二个父分支。 (基本上,检出的分支总是第一个父分支;其他父母是按规范顺序指定给合并命令的分支。)



如果你想找到一个特定的父母的SHA,使用插入符:

解析< SHA> ^ 1
  • 第二个父代: git rev-parse< SHA> ^ 2



  • 等等。

    I need to do a git revert -m , but I have not been able to find any documentation on how the commit parents are numbered. Everything I've seen (including the help pages for rev-parse) just tells me that the parents are numbered but do not say how they are numbered. Could someone point out to me where this is defined and how to determine this?

    解决方案

    git show --format="%P" <SHA>
    

    will give you the parent SHAs of the given commit in numerical order. Most often the one you'll want to specify for git revert will be 1.

    In the case of most merges, the SHA of the branch that was checked out will be the first parent, and the SHA of the branch that was merged in will be the second. (Basically, the checked out branch is always the first parent; the other parents are the branches that were specified to the merge command in the order of their specification.)

    If you want to find the SHA for a particular parent, use the caret operator:

    • First parent: git rev-parse <SHA>^1
    • Second parent: git rev-parse <SHA>^2

    et cetera.

    这篇关于如何找出合并提交父母的编号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆