Created
October 11, 2024 10:42
-
-
Save ChrisLahaye/94c6189ef3ea4d284d4d982b67ff9b7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# | |
# git-fixup - creates a fixup commit and squashes it into the given commit using a rebase. | |
# | |
# Usage: | |
# git fixup <commit> [args...] | |
# | |
# Options: | |
# <commit> The commit to "fix up". | |
# [args...] These arguments are passed verbatim to git-rebase. | |
if [ "$#" -lt 1 ]; then | |
awk 'f && !NF { exit } /^#/ && NR>2 { f=1; sub("^# ?", "", $0); print $0 }' < "${BASH_SOURCE[0]}" | |
exit 1 | |
fi | |
COMMIT=$(git rev-parse $1) | |
shift | |
git commit --fixup=$COMMIT && git -c sequence.editor=: rebase -i --autosquash $COMMIT^ "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment