Last active
August 21, 2022 07:52
-
-
Save therealdreg/eb177753007b061693ad83ef4dfcf61c to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# ~/.bash_profile | |
# alias gitsquash=~/gitsquash.sh | |
set -x | |
args=$* | |
if [ -z "$1" ] | |
then | |
args=$(git log -1 --pretty=%B) | |
fi | |
echo "using as new commit msg last commit msg: $args" | |
git log -n 2 | |
git add -A | |
git commit -m "'changes'" | |
if [ $? -eq 0 ]; then | |
echo "ok, commit is possible" | |
else | |
echo "error, no changes, wtf" | |
exit 1 | |
fi | |
git reset --hard HEAD~2 | |
git merge --squash HEAD@{1} | |
git commit -m "$args" | |
git log -n 2 | |
read -p "press enter to push force" | |
git branch | grep '*' | awk '{print $2}' | xargs -I % git push -f origin % |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment