From e5ca1076d462173c1415f7635753dcfd17b73ed6 Mon Sep 17 00:00:00 2001 From: Daniel Carrillo Date: Fri, 8 Jul 2022 19:29:48 +0200 Subject: [PATCH] [.zshrc] Add alias for git "dirty" squash --- .zshrc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.zshrc b/.zshrc index a5e388e..5c8e3fa 100644 --- a/.zshrc +++ b/.zshrc @@ -73,6 +73,22 @@ kexec () { [ -n "$cid" ] && kubectl exec -ti "$cid" -- "${cmd[@]}" } +# "dirty" squash before merge +git_squash () { + if [ -z $2 ]; then + echo "Usage: $0 \"commit message\"" + return 1 + fi + + local bbranch=$1 + local message=$2 + local cbranch=$(git branch --show-current) + + git reset $(git merge-base $bbranch $cbranch) + git add -A + git commit -m "$message" +} + ##### tilix ##### if [ $TILIX_ID ] || [ $VTE_VERSION ] ; then