I have constructed a tree that contains a couple of files and only exists in the object database. I then added it to the index associated with a path, and committed:
git hash-object -w --stdin
...
abcd1
git hash-object -w --stdin
...
abcd2
git mktree
100755 blob abcd1 a.txt
100755 blob abcd2 b.txt
# resultant tree sha1:
abc123
git update-index --index-info
100755 tree abc123 fake.tree.path
git commit -m "fake.tree.path tree commit"
This seems to work, but what I want is to be able to then:
git checkout fake.tree.path
And have "a.txt" and "b.txt" written into the working dir. Is this possible?
I think what I was doing wrong was this:
git update-index --index-info
100755 tree abc123 fake.tree.path
should have been this:
git update-index --index-info
040000 tree abc123 fake.tree.path
Now doing a git checkout fake.tree.path constructs the directory as desired.
empty index git read-tree --empty
read tree object into index git read-tree <tree-isha>
empty working directory except directory .git ls -a | grep -vw .git | xargs rm -fr | xargs rm -fr
checkout index into working tree git checkout-index -a
references
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With