to recover files that were added to the index but whose changes were lost (e.g. git reset --hard)
git fsck --unreachable | grep commit | cut -d\  -f3 | xargs git show
- git fsck --unreachableto get all the items that are unreachable
- grep committo filter out all entries except for commits (the index will show up as a commit)
- cut -d\  -f3to filter out all but the SHA1s
- xargs git showto show all of the contents of the objects.
Once you've identified the SHA1 that contains the changes that were lost, check it out to get the working tree back into the state of the index at the time git reset --hard was run.