Last active 2 months ago

uk revised this gist 2 months ago. Go to revision

1 file changed, 19 insertions

git-reset.sh(file created)

@@ -0,0 +1,19 @@
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
Newer Older