Skip to content

Instantly share code, notes, and snippets.

@ConradIrwin
Created January 2, 2012 21:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ConradIrwin/1552210 to your computer and use it in GitHub Desktop.
# git-cof
#!/bin/bash -e
TMPFILE=`tempfile`
[ -f .git/index ] || echo "${gitindex?Not a git repository?}"
cp .git/index $TMPFILE
GIT_INDEX_FILE=$TMPFILE git add . -u
echo $(GIT_INDEX_FILE=$TMPFILE git write-tree) $(git whereami) $(git log -1 --oneline) >> .git/tree_backups
git checkout -f "$@"
rm $TMPFILE
# git-foc
#!/bin/bash
TMPFILE=`tempfile`
GIT_INDEX_FILE=$TMPFILE git read-tree $(echo $'$p\n$d\nwq' | ed -s .git/tree_backups | cut -d' ' -f1)
GIT_INDEX_FILE=$TMPFILE git checkout -m .
GIT_INDEX_FILE=$TMPFILE git reset HEAD
rm $TMPFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment