There's something slightly wonky in your instructions, because if I retype:
$ echo 'f1' | git hash-object -w --stdin
I get the same hash:
8e1e71d5ce34c01b6fe83bc5051545f2918c8c2b
but if I try to cut and paste them, I get something very different. This is because something (I'm not sure what) has damaged the single quotes: yours are actually Unicode U+2018 characters, or LEFT SINGLE QUOTATION MARK.
Anyway, as a result I was not quite sure what to do with your third echo
command, but if I assume it's undamaged, it's actually sending:
100644 blob 8e1e71d5ce34c01b6fe83bc5051545f2918c8c2b\tf1.txt 100644 blob 9de77c18733ab8009a956c25e28c85fe203a17d7\tf2.txt
(where each \t
represents a literal tab character) to git mktree
, which will make a tree with one entry. Trying that gives me:
$ printf "100644 blob 8e1e71d5ce34c01b6fe83bc5051545f2918c8c2b\tf1.txt 100644 blob 9de77c18733ab8009a956c25e28c85fe203a17d7\tf2.txt\n" | git mktree
bf9571850c4570cd36ffa426343b81364a855911
which has the same tree-hash, and:
$ git cat-file -p bf9571850
100644 blob 8e1e71d5ce34c01b6fe83bc5051545f2918c8c2b "f1.txt 100644 blob 9de77c18733ab8009a956c25e28c85fe203a17d7\tf2.txt"
(I've left a raw tab in this stackoverflow input, which is a little bit tricky but works with cut-and-paste on a Mac).
Checking out that tree into the current directory will attempt to create a file named f1.txt 100644 blob 9de77c18733ab8009a956c25e28c85fe203a17d7\tf2.txt
(with embedded tab in the name) as one should expect. Presumably your host OS (Windows?) refuses such file names.
Presumably, what you wanted was to print two lines into git mktree
, one each for the f1
and f2
files. The printf
command is probably a better way to do that:
$ printf '%s %s %s\t%s\n' \
> 100644 blob 8e1e71d5ce34c01b6fe83bc5051545f2918c8c2b f1.txt \
> 100644 blob 9de77c18733ab8009a956c25e28c85fe203a17d7 f2.txt |
> git mktree
97da1d249d1b56762add1fb35096a46544416c7f
$ git checkout 97da1 -- .
$ ls
f1.txt f2.txt