Skip to content

Instantly share code, notes, and snippets.

@supremebeing7
Forked from simonwagner/.gitconfig
Created January 25, 2022 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save supremebeing7/e14e889461176b5c29c1e2c1a15282ea to your computer and use it in GitHub Desktop.
Save supremebeing7/e14e889461176b5c29c1e2c1a15282ea to your computer and use it in GitHub Desktop.
Fixup alias for simply fixing a commit.
#This will the fixup command to git
#git fixup $commit will use your current index to fixup the specified commit
#This is done by doing git commit --fixup $commit and then using rebase with autosquash
#Based upon http://stackoverflow.com/a/21148981/460564
[alias]
fixup = "!sh -c '(git diff-files --quiet || (echo Unstaged changes, please commit or stash with --keep-index; exit 1)) && COMMIT=$(git rev-parse $1) && git commit --fixup=$COMMIT && git rebase -i --autosquash $COMMIT~1' -"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment