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

stupid git alias trick

From
Eric Blake <eblake@redhat.com>
Date
Jul 21, 2011, 23:06 UTC
Message-ID
<4E28B0F5.2090705@redhat.com>
Thought I'd share this one, in case anyone else finds it useful.

Every so often, I find myself typing "git ", then pausing while thinking of which command I meant to run (commit, rebase, push?), then realizing that I actually need to make more edits in my editor first. On completion of that task, I come back to terminal and type "git blah<ENTER>" out of habit, not realizing that I'm not starting from an empty prompt. Of course, "git git blah" is not a valid command, but if you have help.autocorrect configured, this ends up auto-correcting to "git init blah" instead, and while that often ends up failing due to unexpected arguments for 'git init', I've actually had scenarios where it succeeds at doing something, but certainly not the "blah" I had in mind.

But thanks to aliases, this is no longer a problem:
git config --global alias.git '!git'

and now, typing "git git blah" results in the execution of the git alias, which in turn runs "git blah" like I intended. Yay for:

git git git git git git git git git git status
-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org
Message 1 of 1 in “stupid git alias trick”
  1. Eric BlakeJul 21, 2011

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.