mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
-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.
28 lines
466 B
Bash
Executable file
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
|
|
|