Skip to content

Commit

Permalink
first undo version
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Refalo committed Jun 7, 2012
1 parent 0dd4579 commit b957f83
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions cmds/g2-undo.sh
@@ -1,6 +1,28 @@
#!/bin/bash
#

# undo file
# undo commit
# undo merge
if [ $# -lt 1 ]
then
echo "Usage : g undo <file|'commit'|'merge'>"
exit
fi

read -p "warning: the action will discard your changes, please confirm (y/n)? " -n 1 -r
echo
[[ $REPLY = [nN]* ]] && exit 0

case "$1" in

"commit")
#TODO: Validate local commits
echo "Undoing last commit and reverting changes to the staging area."
"$GIT_EXE" reset --soft HEAD^
;;
"merge")
#TODO: Validate local commits
echo "Reverting back prior to the last merge."
"$GIT_EXE" reset --hard ORIG_HEAD
;;
*) "$GIT_EXE" checkout -- "$1"
;;
esac

0 comments on commit b957f83

Please sign in to comment.