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

Re: Using '--help' for aliases

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jun 24, 2017, 17:20 UTC
Message-ID
<20170624172011.5afp3qhrec5ovynl@genre.crustytoothpaste.net>
In-Reply-To
<1498070489.32360.14.camel@gmail.com>
On Thu, Jun 22, 2017 at 12:11:29AM +0530, Kaartic Sivaraam wrote:
Show 11 quoted lines
> I am yet another user of 'git alias' (who wouldn't ?). It has become so
> natural to me to use the aliased version that at some point of time I
> tried the following,
> 
> > $ git co --help
> > `git co' is aliased to `checkout'
> 
> That made me wonder. Git is able to inform the user that 'co' is
> aliased to 'checkout' but isn't it possible for it to take one step
> more to display help ? Just wondering if there were any reason for not
> doing it.

It's possible to do if "co" is an alias for "checkout", but it works less well when co is the following[0]:

	co = "!f() { if git checkout -h | grep -qs recurse-submodules; \
		then git checkout --recurse-submodules \"$@\"; \
		else git checkout \"$@\" && git sui; \
		fi; };f"

If this alias were to run on a Git with that option but without checkout --recurse-submodules, then it would print help and then update submodles, which isn't what I want.

[0] sui is an alias for submodule update --init.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204
Previous: Samuel Lijin
Message 5 of 5 in “Using '--help' for aliases”
  1. Kaartic SivaraamJun 21, 2017
  2. Jeff KingJun 21, 2017
  3. Kaartic SivaraamJun 21, 2017
  4. Samuel LijinJun 22, 2017
  5. brian m. carlsonJun 24, 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.