Git Fixup helper.

Steve Wirt's picture

Have you ever done your git commit and then found just one little bit that you had to change, or you found you left in a debug command?

Its a tedium to add a new commit with your fixup and then have to do an interactive rebase to squash or fixup that commit into the previous commit.   Here is a little helper that can get you to the end result quickly.

git commit --amend -C HEAD

Of course that is a pain to remember.. so make a shell alias out of it.

alias gfixup="git commit --amend -C HEAD"

In use it would look like this

git add myFileName.php
git commit -m "Adding some awesome code to myFileName.php"

// Bugger found a bit of debug code I just removed.

git add myFileName.php

//That just committed my debug removal into the previous commit without making a new commit in the log.

CAUTION:  This does rewrite history, so only use this if you are sure no one has had a chance to grab your previous commit.



Groups audience: 

- Private group -


Public - accessible to all