#!/bin/sh . git-sh-setup-script || die "Not a git archive" if [ -n "$(git-diff-files)" ]; then echo The following files should be updated! echo git-diff-files | awk '{print $6}' fi undostack=$GIT_DIR/undostack headtree=$(git-cat-file commit $(cat $GIT_DIR/HEAD) | head -n 1 | sed -e 's/tree //') undotree=$(git-write-tree) if [ $headtree == $undotree ]; then echo There are no changes to undo. else { echo $headtree echo $undotree } >> $undostack echo Saved current state as tree $undotree. echo Reverting to HEAD, $headtree... git-checkout-script -f fi