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

-h prints alias information even for grep

From
KBKevin Brodsky <kevin.brodsky@arm.com>
Date
Jul 25, 2025, 08:17 UTC
Message-ID
<1c3a0463-36ee-4a2d-92e0-fac9c0bf77da@arm.com>
Hi,
I've noticed a strange interaction that probably wasn't intended.

The -h flag typically means "help", and if passed to an aliased command an extra line is printed to describe the alias. This also holds for the grep command, if no other argument is passed.

Things get weirder if grep is passed valid arguments, because in that case -h means something else (suppressing filename output). Of course no help message is printed in that case, but the alias information is still printed!

Example:
$ git g -h -A20 alias .gitconfig
'g' is aliased to 'grep'
[alias]
[...]
    g    = grep
----

It seems like that alias information line should be tied to the printing of the help message, rather than the -h flag?

I noticed this behaviour years ago and I still do with the latest version of Git (2.50.1).

Cheers, Kevin

Next: René Scharfe
Message 1 of 9 in “-h prints alias information even for grep”
  1. Kevin BrodskyJul 25, 2025
  2. git: show alias info only with lone -hRené Scharfe, Jul 25, 2025
  3. Junio C HamanoJul 25, 2025
  4. Jeff KingJul 26, 2025
  5. D. Ben KnobleJul 26, 2025
  6. D. Ben KnobleJul 26, 2025
  7. Jeff KingJul 29, 2025
  8. Junio C HamanoJul 28, 2025
  9. Jeff KingJul 29, 2025

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.