在git-scm
書的git internals章有怎樣的git樹可以創建一個例子:創建樹,而無需使用臨時區域
Git normally creates a tree by taking the state of your staging area or index and writing a series of tree objects from it. So, to create a tree object, you first have to set up an index by staging some files.
然後他們列出我可以用它來創建樹命令。我的問題是我是否可以不使用索引(暫存區)創建一棵樹?例如,而不是這樣做:
git update-index --add --cacheinfo 100644 83baae618... test.txt
使用這樣的事情:
git create tree --add --cacheinfo 100644 83baae618... test.txt
更新基於司馬義·巴達維的雁:
$ echo 'making tree' | git hash-object -w --stdin
07dae42a0730df1cd19b0ac693c6894a02ed6ad0
然後
$ echo -e '100644 blob 07dae42a0730df1cd19b0ac693c6894a02ed6ad0 \maketree.txt' | git mktree
fatal: input format error: 100644 blob 07dae42a0730df1cd19b0ac693c6894a02ed6ad0 \maketree.txt
'git mktree'做到這一點 – 2014-12-03 18:46:30