28 Apr 2011
A nice git option I stumbled upon today – amend.
Typical scenario – you’ve done a local check-in, then notice there’s a typo in your code comments. Fix up the typo, then use – – amend to re-check-in, without having to do a reset/revert. For example:
git add foo.file git ci -m "added the frob feature to the whiz-bang" ... notice and fix typo in foo.file ... git add foo.file git ci --amend
When you do the amend check-in, your editor will pop up, allowing you to re-edit the commit message if desired.
Obviously, if you’ve done a commit to a remote/public repository, amend has issues, similar to reset.
Also, I have entries like this in my .gitconfig, hence “git ci” rather than “git commit”.
[alias] ci = commit co = checkout st = status br = branchcomments powered by Disqus