tj.git-extras/bin/git-clear
Edwin Kofler 5c3fb1b062
Some checks failed
ci / test (push) Has been cancelled
ci / lint (push) Has been cancelled
ci / typo (push) Has been cancelled
ci / build (macos-latest) (push) Has been cancelled
ci / build (ubuntu-latest) (push) Has been cancelled
Improve warning for git clear (#1168)
2024-09-30 10:07:52 +08:00

44 lines
789 B
Bash
Executable file

#!/usr/bin/env bash
PROGNAME="git-clear"
FORCE=0
function _usage() {
cat << EOF
usage: $PROGNAME options
usage: $PROGNAME -h|help|?
clear git repository
OPTIONS:
-f, --force Force clear without questioning user
-h, --help, ? Show this message
EOF
}
# Read arguments
while [ "$1" != "" ]; do
case $1 in
-f|--force)
FORCE=1
;;
-h|--help|?)
_usage
exit 1
;;
esac
shift
done
# Only wait for answer if not forced by user
if [[ $FORCE == 0 ]]; then
echo -n "Sure? - THIS COMMAND MAY DELETE FILES THAT CANNOT BE RECOVERED, including those in .gitignore [y/N]: "
read -r clean
else
clean=y
fi
if [ "$clean" == "y" ]; then
git clean -d -f -x && git reset --hard
fi