Bash script github pages rollback

#!/usr/bin/env bash

echo "Insert commit hash" read commitHash
branch=$(git branch --show-current)
branchpatch=patch

if [ -z "$commitHash" ]; then
  echo "No commit hash supplied"
  exit
fi

git checkout $branch
git reset --hard $commitHash
git checkout -b $branchpatch
git add -A
git commit -am "hotfix patch ${branch}@${commitHash}" 2> /dev/null
git checkout $branch
git checkout $branchpatch .
git add -A
git commit -am "hotfix patch ${branch}@${commitHash}" 2> /dev/null
git push origin $branch
git branch -D $branchpatch

Usage to rollback

sh filename.sh
  • input your commit hash to rollback
  • wait until finished