Added convenience shell scripts

This commit is contained in:
raccoon
2026-03-02 12:06:35 +05:00
parent c9eec43b74
commit cd4cd13b54
6 changed files with 165 additions and 0 deletions

33
repo-reset.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/sh -e
cd "$(dirname "$(readlink -f "$0")")"
git rev-parse --is-inside-work-tree >/dev/null
upstream="$(git rev-parse --abbrev-ref "@{u}" 2>/dev/null || true)"
if [ -z "$upstream" ]; then
echo "*** ERROR: No upstream is configured for current branch"
exit 1
fi
git fetch --all
echo ""
echo "Going to reset current branch to: ${upstream}"
echo ""
echo "*** WARNING: These local commits will be lost:"
git log "${upstream}..HEAD" --oneline
echo ""
echo "*** WARNING: These local files will be reset:"
git diff "HEAD..${upstream}" --name-only
printf "\nExecute [Y,N]?"; read -r yn
if [ "$yn" = "${yn#[Yy]}" ]; then
echo "Aborting reset..."
else
git reset --hard "$upstream"
echo "Done."
fi
exit 0