let\'s say that we have an hotfixes branch which was created from master. we added commits to hotfixes, but those commits were not use
Based on a few of the answers in this thread, I did the following script with a few prompts to reduce risk of messing stuff up:
#!/bin/bash
# Questions for loop:
for value in {1..3}
do
# Asking if user wants to reset hotfix:
if [ "$value" == "1" ] ;then
echo -n "Are you sure you want to hard reset the hotfix branch (y/n)? "
read answer
if [ "$answer" == "${answer#[Yy]}" ] ;then
echo 'Okay, maybe next time.'
exit
fi
fi
# Asking if user is in void:
if [ "$value" == "2" ] ;then
echo -n "Are you in the void branch (y/n)? "
read answer
if [ "$answer" == "${answer#[Yy]}" ] ;then
echo 'You should checkout to the void branch.'
exit
fi
fi
# Asking if user has any uncommited changes:
if [ "$value" == "3" ] ;then
echo -n "Do you have any uncommited changes (y/n)? "
read answer
if [ "$answer" == "${answer#[Nn]}" ] ;then
echo 'You should commit your changes to avoid losing them.'
exit
fi
fi
done
echo 'Resetting...'
git checkout void
git branch -f hotfix origin/master
git push -f origin hotfix
100% open to any feedback to improve this script.