Instead of git add you should have git-add. Few bother to get this right.
Instead of git add you should have git-add. Few bother to get this right.
> Among other things it makes the shell’s ! commands harder to use.
How so?
I can't think of any huge positives from using subcommands. I know for a fact that that will take longer to write and add some complexity to --args-* and I also feel like getting a quick --help option would be a lot more cumbersome.
Maybe a good way there is to list commands then tabbed/dashed indented under the root command list its subcommands.
git --help
git add --help
The former returns general information about the whole git executable, while the latter returns specific details about the add command.
It also gives an immediate intuition of entering a whole different flow that can not be composed with other flows, something that you don't have with --args There is a hierarchy between commands and options that is not expressed when both use the -- syntax
They prefer (executable --actions-option) which is a command flag as opposed to chaining commands off one another.
Example: https://i.imgur.com/dxXwRzD.gifv
The `git add’ approach always reminds me of using a mouse and a menu (ugh): select the git option, drag down until you get to the “add” subotion and then…. Supposedly that’s more “discoverable” and maybe it is, but you don’t need discoverability for the things you use every day!
!! which you know runs the previous command in your history. It's just short for !-1 !123 runs the 123th command in your history !gi runs the most recent command in your history that begins with letters g and i
!* is the args to the most recent command !$ is the last argument to the most recent command !:0 is argv[0] of the most recent command (i.e. the program name)
These can be combined: !g:$ is the last argument to the most recent command that began with g
They are also really handy in backquotes since you can do things like grep foo `!find | egrep .cc` because your find command was almost right
Sometimes you can get away with a ^ substitution:
git add foo.cc bar.cc
oops
^add^resetThere are a lot of such commands that let you use the basename of the argument etc. After a short while they are so automatic they are easier to type than the actual command name ("I just want to do that thing again but with this filename"). These have actually become so deeply wired that I had to think to write them down because I use them “without thinking”.
So this is handy with normal commands:
git-add foo.cc
<do some stuff>
!g:0 bar.h
git-add foo.cc bar.cc
<do some stuff... oh wait, I didn't mean to do this>
git-reset !g:*
But with subcommands, you end up matching against all the git operations; !* matches all the arguments to the `git` command including the subcommand so you can't conveniently say "yes, that last git command but I want to change the subcommand"