I have a script that uses git write-tree to make up for the deficiencies in git stash, it works perfect unless I ctrlC the script.
[... other parts of script ...]
exec('git add -f .');
workingTreeHash=exec('git write-tree');
exec('git checkout -f [...]');
At this point the I ^C the script and thus lost the write-tree hash variable workingTreeHash.
My attempt at recovery:
$ git fsck --lost-found --full --unreachable
$ git config gc.auto 0
$ (
for i in $(ls .git/lost-found/{commit,other}/*);do
git show $(basename $i);
done;
)
|grep -iae 'unique modifications';
showed nothing... so where did the lost git add -f .;git write-tree object go? Where can it be found. (I am aware of git workspaces, I will try that as an alternative for the script).
This isn't a high priority, just for future reference in case this happens again with something important.
(it's probably the first one), then
git showthem.For me, I've made a change since my last commit, so I get
and the full hash would be
git rev-parse 1ae2dif you don't want to type it.c72a7's the commit,e69d, you might even recognize that hash, it's an empty file I added by mistake.Also, if you know you haven't touched the index since writing it,
git write-treeis idempotent, just do it again, you'll get the same tree.