Skip to content

Instantly share code, notes, and snippets.

@therealdreg
Last active August 21, 2022 07:52
Show Gist options
  • Save therealdreg/eb177753007b061693ad83ef4dfcf61c to your computer and use it in GitHub Desktop.
Save therealdreg/eb177753007b061693ad83ef4dfcf61c to your computer and use it in GitHub Desktop.
#!/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