简体   繁体   English

git cat-file使用树状符号

[英]git cat-file using treeish notation

When using the command git cat-file as following: 当使用如下命令git cat-file时:

git cat-file -p master^^{tree}

It works well and shows the content of the tree object, 2 commits in the past. 它运行良好并显示了树对象的内容,过去有2次提交。

However, when using the same command, changing the ^^ for ~2, it shows the following error: 但是,当使用相同的命令时,将^^更改为〜2,则会显示以下错误:

git cat-file -p master~2{tree}

fatal: Not a valid object name master~2{tree}

Is this syntax allowed? 是否允许这种语法? Otherwise, how could I retrieve the tree object 100 commits in the past? 否则,如何检索过去提交的树对象100?

Your first command is actually only going 1 commit into the past, not 2. The first caret is selecting the parent of master , but the second one is part of the ^{type} syntax. 您的第一个命令实际上只执行1次提交,而不是2次。第一个插入符号选择master的父级,但是第二个是^{type}语法的一部分。 To go to the parent's parent and convert to a tree, you need master^^^{tree} . 要转到父母的父母并转换为树,您需要master^^^{tree}

This also explains what's wrong with your second command: it needs to be master~2^{tree} . 这也解释了第二条命令出了什么问题:它必须是master~2^{tree}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM