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 <COMMAND> 75 76Commands: 77 push 78 pop 79 apply 80 help Print this message or the help of the given subcommand(s) 81 82Options: 83 -m, --message <MESSAGE> 84 -h, --help Print help 85 86$ git stash push -h 87Usage: git[EXE] stash push [OPTIONS] 88 89Options: 90 -m, --message <MESSAGE> 91 -h, --help Print help 92 93$ git stash pop -h 94Usage: git[EXE] stash pop [STASH] 95 96Arguments: 97 [STASH] 98 99Options: 100 -h, --help Print help 101 102$ git stash -m "Prototype" 103Pushing Some("Prototype") 104 105$ git stash pop 106Popping None 107 108$ git stash push -m "Prototype" 109Pushing Some("Prototype") 110 111$ git stash pop 112Popping None 113 114``` 115 116External subcommands: 117```console 118$ git custom-tool arg1 --foo bar 119Calling out to "custom-tool" with ["arg1", "--foo", "bar"] 120 121``` 122 123Last argument: 124```console 125$ git diff --help 126Compare two commits 127 128Usage: git[EXE] diff [OPTIONS] [COMMIT] [COMMIT] [-- <PATH>] 129 130Arguments: 131 [COMMIT] 132 [COMMIT] 133 [PATH] 134 135Options: 136 --color[=<WHEN>] [default: auto] [possible values: always, auto, never] 137 -h, --help Print help 138 139$ git diff 140Diffing stage..worktree (color=auto) 141 142$ git diff ./src 143Diffing stage..worktree ./src (color=auto) 144 145$ git diff HEAD ./src 146Diffing HEAD..worktree ./src (color=auto) 147 148$ git diff HEAD~~ -- HEAD 149Diffing HEAD~~..worktree HEAD (color=auto) 150 151$ git diff --color 152Diffing stage..worktree (color=always) 153 154$ git diff --color=never 155Diffing stage..worktree (color=never) 156 157``` 158