aboutsummaryrefslogtreecommitdiff
path: root/git/git-fixup.sh
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2025-10-06 00:48:48 +0300
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2025-10-06 00:48:48 +0300
commitad9e7cd5117c965222aae708f660e56d537914fc (patch)
tree580006656ec76513500170e5646e92e7819c6c0b /git/git-fixup.sh
downloadsnippets-ad9e7cd5117c965222aae708f660e56d537914fc.tar.gz
imported all of my Github gists from https://gist.github.com/rhaberkorn
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~~