git-reset.sh
· 512 B · Bash
Raw
#!/bin/bash
git status
echo
read -p "Type 'y' to confirm reset and pull (Enter = yes, n = cancel): " confirm </dev/tty
# Treat empty input (Enter) as "y"
confirm="${confirm:-y}"
if [[ "$confirm" == "y" ]]; then
echo "Proceeding with reset and pull..."
git reset --hard HEAD && git clean -fd && git fetch origin && git pull origin main
git status
elif [[ "$confirm" == "n" ]]; then
echo "Operation cancelled by user (n)."
else
echo "Operation cancelled. Only 'y' or Enter will proceed."
fi
| 1 | #!/bin/bash |
| 2 | |
| 3 | git status |
| 4 | |
| 5 | echo |
| 6 | read -p "Type 'y' to confirm reset and pull (Enter = yes, n = cancel): " confirm </dev/tty |
| 7 | |
| 8 | # Treat empty input (Enter) as "y" |
| 9 | confirm="${confirm:-y}" |
| 10 | |
| 11 | if [[ "$confirm" == "y" ]]; then |
| 12 | echo "Proceeding with reset and pull..." |
| 13 | git reset --hard HEAD && git clean -fd && git fetch origin && git pull origin main |
| 14 | git status |
| 15 | elif [[ "$confirm" == "n" ]]; then |
| 16 | echo "Operation cancelled by user (n)." |
| 17 | else |
| 18 | echo "Operation cancelled. Only 'y' or Enter will proceed." |
| 19 | fi |