aboutsummaryrefslogtreecommitdiff
path: root/git/git-fixup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'git/git-fixup.sh')
-rwxr-xr-xgit/git-fixup.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/git/git-fixup.sh b/git/git-fixup.sh
new file mode 100755
index 0000000..9dfc2ee
--- /dev/null
+++ b/git/git-fixup.sh
@@ -0,0 +1,12 @@
+#!/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~~