Last active 2 months ago

git-reset.sh Raw
1#!/bin/bash
2
3git status
4
5echo
6read -p "Type 'y' to confirm reset and pull (Enter = yes, n = cancel): " confirm </dev/tty
7
8# Treat empty input (Enter) as "y"
9confirm="${confirm:-y}"
10
11if [[ "$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
15elif [[ "$confirm" == "n" ]]; then
16 echo "Operation cancelled by user (n)."
17else
18 echo "Operation cancelled. Only 'y' or Enter will proceed."
19fi