Jun 292018
 

Every once in a while I figure a typo as I am hitting git commit. Mind you, it’s not that I am making a typo once in a while – I do typos all the time – I only notice them once in a while. :)

What follows is a common pair of commands:

$ git reset --soft HEAD~
$ git commit -m"Corrected spelling."

As I did with other git operations I do often enough, I decided to make it an alias:

$ git config --global alias.redo '!git reset --soft HEAD~ && git commit'

Now I can use a single git command to do correction:

$ git redo -m"Corrected spelling."

Even better, if comment is not given, command will simply move the latest commit back into the staging area.

Might not be a huge change but it does make a common operation faster.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.