In gitscm.org documentation, under git objects chapter, it uses the command below, but trying it out gives me "zsh: no matches found: master^{tree}". Any idea what's incorrect?
git cat-file -p master^{tree}
I've found that when specifying those more tricky git revision parameters, I have to quote them
git cat-file -p "master^{tree}"
while leaving out the "
fails.
This behavior and and the reason for it varies with the platform:
^
character is used for escaping. So, as an alternative, you can write git cat-file -p master^^{tree}
^
character is used for globbing(thanks to Wumpus Q. Wumbley and kostix for explanations)
You can run noglob whatever
if you want to run whatever
without globbing. I have it defined as an alias for rake
, for instance.
在 Windows 中执行该步骤之前需要克隆项目。
The various possible cases for this error:
Depending on what shell you use, you may encounter errors when using the master^{tree} syntax.
In CMD on Windows, the ^ character is used for escaping, so you have to double it to avoid this: git cat-file -p master^^{tree}. When using PowerShell, parameters using {} characters have to be quoted to avoid the parameter being parsed incorrectly: git cat-file -p 'master^{tree}'.
If you're using ZSH, the ^ character is used for globbing, so you have to enclose the whole expression in quotes: git cat-file -p "master^{tree}".
As villasv pointed out that: " If you do get "Not a valid object name master^{tree}", make sure you have at least one commit done. The master branch does not exist yet immediately after git init. – villasv " Since The master^{tree} syntax specifies the tree object that is pointed to by the last commit on your master branch as referenced to git object After making commit to current change, git cat-file -p 'master^{tree}'
can be executed.
Depending on what shell you use, you may encounter errors when using the master^{tree} syntax.
In CMD on Windows, the ^ character is used for escaping, so you have to double it to avoid this: git cat-file -p master^^{tree}. When using PowerShell, parameters using {} characters have to be quoted to avoid the parameter being parsed incorrectly: git cat-file -p 'master^{tree}'.
If you're using ZSH, the ^ character is used for globbing, so you have to enclose the whole expression in quotes: git cat-file -p "master^{tree}".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.