tj.git-extras/bin/git-undo
Leila Muhtasib 6459db39aa git-undo now includes -h|--hard option.
-h option allows you to undo the last commit without keeping the
changes in the local working directory. Use with care.
Updated documentation to include new option.
2012-07-22 22:27:37 +02:00

28 lines
466 B
Bash
Executable file

#!/bin/sh
hard='no'
digit=1
parseArgs () {
for var in "$@"; do
if [ "$var" = "--hard" -o "$var" = "-h" ]; then
hard='yes';
elif `echo $var | grep -q [^[:digit:]]`; then
echo "You entered an invalid option. Valid options are [--hard|-h] [commitcount]." 1>&2
exit 1;
else
digit=$var
fi
done
}
parseArgs $@
if [ "$hard" = "yes" ]; then
git reset --hard HEAD~$digit
else
git reset --soft HEAD~$digit
git reset
fi