git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Usability suggestion: Catch `git commit -amend`

From
RGRyan Govostes <rgovostes@gmail.com>
Date
Nov 16, 2017, 04:06 UTC
Message-ID
<CAMtyXZYMU6fR4MTzRqOCgnqdhNhAVbLu7kUqGW6UXf9wq5P1zQ@mail.gmail.com>

Despite being a native English speaker, I've often typo'd when trying to invoke `git commit --amend`. Recently I wrote `git commit -ammend` which of course added everything to the commit and attached the commit message "mend".

This doesn't seem to be an uncommon error, there are 64,000 commits like this on GitHub: https://github.com/search?utf8=✓&q=mend&type=Commits

The search for simply "end" (as in `-amend`) returns millions of hits but it's hard to tell how many of those are false positives.

It might be reasonable to try to catch `-amend` (at least) and prevent an errant commit. Trying to roll back a commit is a place where people often get into trouble and get confused about the state of their repository. (Of course, if they just cursor-up and fix the typo, now they're editing the "end" commit and not the one they were trying to amend in the first place.)

Git could suggest the user instead pass the commit message as a separate argument, like `-am end` if they really want to do it.

I'm OK with getting an error if I type `--ammend`, but it is nice that Git does do spell check on subcommand names. That would make it easier to figure out which argument I mistyped. (In this case, there's usually only one.)

Ryan
Message 1 of 1 in “Usability suggestion: Catch `git commit -amend`”
  1. Ryan GovostesNov 16, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.