Sunday, July 13, 2008

git commit --amend gives me an erection

Sometimes at work, I find out something that is so fucking awesome I just have to tell someone. Unfortunately, there usually is no one at work to tell since no one would understand my ravings. At times like these the best I can do is check left, then right, then quietly jack off under my desk.

Needless to say, when I discovered the --amend flag for git commit, my righty was down my pants in a flash.

Lemme explain the use case. One day that evil porn star genius Doctor Coctopus decides to upgrade the AI in his extra appendages to allow him to act in multiple sex scenes simultaneously. He hacks furiously at the mainframe for a bit and arrives at a good point to commit his work. He does the following:

git add pron_hacks.c
git add more_pron_hacks.c
git add extreme_pron_hacks.c
git commit

He then does some more hacks before realising that he forgot to add some stuff to the previous commit! Fuck!

If he didn't know about git commit --amend he might do something like this:

git reset --soft HEAD~1
git add auxiliary_pron_hacks.c
git commit

He would then have to remember the commit message he typed and reproduce it (adding some extra bits for the new stuff).

But, if he did know about git commit --amend he would do something like this instead:

git add auxiliary_pron_hacks.c
git commit --amend

This would alter the previous commit, incorporating the new changes. It would also prefill his commit message with the old commit message.


I forget to add code to my commits all the fucking time (probably because I use git add -i and go into patch mode so much), so for me the --amend flag is THA SHIT.

No comments:

Post a Comment