Created
November 4, 2022 18:27
-
-
Save ricardoaugusto/4c4ca52294073be6b066c28b8e410c51 to your computer and use it in GitHub Desktop.
Resets a commit and push --force
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# usage: sh git-reset.sh -h someCommitHash -t some/feature-branch | |
while getopts h:t: flag | |
do | |
case "${flag}" in | |
h) hashed=${OPTARG};; | |
t) target=${OPTARG};; | |
esac | |
done | |
if [$hashed === ''] | |
then | |
hashed=$(git rev-parse --short HEAD) | |
fi | |
if [$target === ''] | |
then | |
target=$(git symbolic-ref --short HEAD) | |
fi | |
git reset --hard $hashed | |
git push origin $target --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment