git-lost-found.shon commit Everyday: some examples. (44db136)
   1#!/bin/sh
   2
   3GIT_DIR=`git-rev-parse --git-dir` || exit $?
   4laf="$GIT_DIR/lost-found"
   5rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit
   6
   7git fsck-objects |
   8while read dangling type sha1
   9do
  10        case "$dangling" in
  11        dangling)
  12                if git-rev-parse --verify "$sha1^0" >/dev/null 2>/dev/null
  13                then
  14                        dir="$laf/commit"
  15                        git-show-branch "$sha1"
  16                else
  17                        dir="$laf/other"
  18                fi
  19                echo "$sha1" >"$dir/$sha1"
  20                ;;
  21        esac
  22done