1Git is an example of several common subcommand patterns. 2 3Help: 4```console 5$ git 6? failed 7A fictional versioning CLI 8 9Usage: git[EXE] <COMMAND> 10 11Commands: 12 clone Clones repos 13 diff Compare two commits 14 push pushes things 15 add adds things 16 stash 17 help Print this message or the help of the given subcommand(s) 18 19Options: 20 -h, --help Print help 21 22$ git help 23A fictional versioning CLI 24 25Usage: git[EXE] <COMMAND> 26 27Commands: 28 clone Clones repos 29 diff Compare two commits 30 push pushes things 31 add adds things 32 stash 33 help Print this message or the help of the given subcommand(s) 34 35Options: 36 -h, --help Print help 37 38$ git help add 39adds things 40 41Usage: git[EXE] add <PATH>... 42 43Arguments: 44 <PATH>... Stuff to add 45 46Options: 47 -h, --help Print help 48 49``` 50 51A basic argument: 52```console 53$ git add 54? failed 55adds things 56 57Usage: git[EXE] add <PATH>... 58 59Arguments: 60 <PATH>... Stuff to add 61 62Options: 63 -h, --help Print help 64 65$ git add Cargo.toml Cargo.lock 66Adding ["Cargo.toml", "Cargo.lock"] 67 68``` 69 70Default subcommand: 71```console 72$ git stash -h 73Usage: git[EXE] stash [OPTIONS] 74 git[EXE] stash push [OPTIONS] 75 git[EXE] stash pop [STASH] 76 git[EXE] stash apply [STASH] 77 git[EXE] stash help [COMMAND]... 78 79Options: 80 -m, --message <MESSAGE> 81 -h, --help Print help 82 83git[EXE] stash push: 84 -m, --message <MESSAGE> 85 -h, --help Print help 86 87git[EXE] stash pop: 88 -h, --help Print help 89 [STASH] 90 91git[EXE] stash apply: 92 -h, --help Print help 93 [STASH] 94 95git[EXE] stash help: 96Print this message or the help of the given subcommand(s) 97 [COMMAND]... Print help for the subcommand(s) 98 99$ git stash push -h 100Usage: git[EXE] stash push [OPTIONS] 101 102Options: 103 -m, --message <MESSAGE> 104 -h, --help Print help 105 106$ git stash pop -h 107Usage: git[EXE] stash pop [STASH] 108 109Arguments: 110 [STASH] 111 112Options: 113 -h, --help Print help 114 115$ git stash -m "Prototype" 116Pushing Some("Prototype") 117 118$ git stash pop 119Popping None 120 121$ git stash push -m "Prototype" 122Pushing Some("Prototype") 123 124$ git stash pop 125Popping None 126 127``` 128 129External subcommands: 130```console 131$ git custom-tool arg1 --foo bar 132Calling out to "custom-tool" with ["arg1", "--foo", "bar"] 133 134``` 135 136Last argument: 137```console 138$ git diff --help 139Compare two commits 140 141Usage: git[EXE] diff [OPTIONS] [COMMIT] [COMMIT] [-- <PATH>] 142 143Arguments: 144 [COMMIT] 145 [COMMIT] 146 [PATH] 147 148Options: 149 --color[=<WHEN>] [default: auto] [possible values: always, auto, never] 150 -h, --help Print help 151 152$ git diff 153Diffing stage..worktree (color=auto) 154 155$ git diff ./src 156Diffing stage..worktree ./src (color=auto) 157 158$ git diff HEAD ./src 159Diffing HEAD..worktree ./src (color=auto) 160 161$ git diff HEAD~~ -- HEAD 162Diffing HEAD~~..worktree HEAD (color=auto) 163 164$ git diff --color 165Diffing stage..worktree (color=always) 166 167$ git diff --color=never 168Diffing stage..worktree (color=never) 169 170``` 171