Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Olivier Refalo
committed
Jun 7, 2012
1 parent
0dd4579
commit b957f83
Showing
1 changed file
with
25 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |