Skip to content

Instantly share code, notes, and snippets.

@Zitrax
Created April 21, 2016 13:30
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 Zitrax/fe01e7422817f4ba377348bac56afd10 to your computer and use it in GitHub Desktop.
Save Zitrax/fe01e7422817f4ba377348bac56afd10 to your computer and use it in GitHub Desktop.
Fixup git alias
[alias]
fixup = !sh -c 'git commit -a --fixup=`git rev-list master.. | tail -1` && git commit --amend -m\"`git show -s --format=%s`\" -m\"$1\"' -
@Zitrax
Copy link
Author

Zitrax commented Apr 21, 2016

Something I need to do often in my git workflow is to add a fixup commit that fixes up the first commit on the branch and add a description in the body of the fixup commit message.

Thus this alias do the following:

  • Find the first commit on the branch (assumed to be branched off master)
  • Create a fixup commit including all local changes
  • Amend the just created commit with a simple description

Usage:

git fixup "Removed debug print"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment