Skip to content

Instantly share code, notes, and snippets.

@rhaberkorn
Created March 14, 2025 18:59
Show Gist options
  • Save rhaberkorn/8222112f3573ec2b3994ce863066000b to your computer and use it in GitHub Desktop.
Save rhaberkorn/8222112f3573ec2b3994ce863066000b to your computer and use it in GitHub Desktop.
Squash changes into the last commit
#!/bin/sh
# Creates a commit from the given files and automatically
# squashes it into the last commit on HEAD.
set -e
if [ "x`git branch -r --contains HEAD`" != x ]; then
echo "HEAD commit already pushed?"
exit 1
fi
git commit --fixup=HEAD "$@"
git rebase --autostash --autosquash HEAD~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment