I'm an idiot. I started a new project and spent a few hours on it, then decided it should be in git. So I did a git init
and then did a git add .
. I then realized I hadn't copied a .gitignore so before commiting I wanted to go back and add that.
Without thinking I did a git reset --hard
and the obvious happened.
However - if i do a git fsck
there are a load of dangling blobs, and a "missing tree".
> git fsck
notice: HEAD points to an unborn branch (master)
Checking object directories: 100% (256/256), done.
notice: No default references
dangling blob 04600b0b0185210bb56c8510538d8578b9451267
dangling blob 3b5f525f59d5fdf71a148d9bc04a80912006c5f7
dangling blob 3f4f89e0767381f0dae2c24b25abee3dffbca061
missing tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
dangling blob 504f47a8ce6bd4dc3bd1694da5ed3173efe17703
dangling blob 53c94aabbffadab697f9e689a0037999bf906032
etc...
So I can get all the files back - but is there a quick easy way to get them all back with filenames and in the right place using that missing tree?
git reset HEAD@{1}
as suggested elsewhere only gives
fatal: ambiguous argument 'HEAD@{1}': unknown revision or path not in the working tree.