V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
AndyAO
V2EX  ›  程序员

获取 Git 中特定 commit-ish 全部 parents 的方法

  •  1
     
  •   AndyAO · 2021-08-23 10:05:06 +08:00 · 972 次点击
    这是一个创建于 970 天前的主题,其中的信息可能已经有所发展或是发生改变。

    效率最高的方式

    git rev-parse <commit-ish>^@,parent 会显示在不同的行中,不论是查看还是解析,都会很容易。而且这是个底层命令,效率会很高。

    要注意的是不要使用<commit-ish>^,这只会显示首个 parent,而不是 parents 。

    其他方式盘点

    下面的--pretty=%P更换为--pretty=raw也可以,后者会显示更多内容。

    1. git cat-file -p <commit-ish>^{}
    2. git show -p <commit-ish>^{} --pretty=%P --no-patch
    3. git log --pretty=%P -n 1 <commit-ish>
    4. git rev-list --parents -n 1 <commit-ish>
    1 条回复    2021-08-23 11:08:30 +08:00
    AlphaTr
        1
    AlphaTr  
       2021-08-23 11:08:30 +08:00
    git checkout --orphan 参数?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2803 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 13:15 · PVG 21:15 · LAX 06:15 · JFK 09:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.