2021-11-30 18:30:19 +00:00
|
|
|
Git is an example of several common subcommand patterns.
|
|
|
|
|
|
|
|
Help:
|
2022-01-05 16:54:33 +00:00
|
|
|
```console
|
2021-11-30 18:30:19 +00:00
|
|
|
$ git
|
|
|
|
? failed
|
|
|
|
A fictional versioning CLI
|
|
|
|
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: git[EXE] <COMMAND>
|
2021-11-30 18:30:19 +00:00
|
|
|
|
2022-08-31 02:38:37 +00:00
|
|
|
Commands:
|
2022-09-07 20:29:15 +00:00
|
|
|
clone Clones repos
|
|
|
|
diff Compare two commits
|
|
|
|
push pushes things
|
|
|
|
add adds things
|
|
|
|
stash
|
|
|
|
help Print this message or the help of the given subcommand(s)
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2022-08-26 15:59:27 +00:00
|
|
|
Options:
|
2022-09-07 20:29:15 +00:00
|
|
|
-h, --help Print help information
|
2022-08-26 15:59:27 +00:00
|
|
|
|
2021-11-30 18:30:19 +00:00
|
|
|
$ git help
|
|
|
|
A fictional versioning CLI
|
|
|
|
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: git[EXE] <COMMAND>
|
2021-11-30 18:30:19 +00:00
|
|
|
|
2022-08-31 02:38:37 +00:00
|
|
|
Commands:
|
2022-09-07 20:29:15 +00:00
|
|
|
clone Clones repos
|
|
|
|
diff Compare two commits
|
|
|
|
push pushes things
|
|
|
|
add adds things
|
|
|
|
stash
|
|
|
|
help Print this message or the help of the given subcommand(s)
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2022-08-26 15:59:27 +00:00
|
|
|
Options:
|
2022-09-07 20:29:15 +00:00
|
|
|
-h, --help Print help information
|
2022-08-26 15:59:27 +00:00
|
|
|
|
2021-11-30 18:30:19 +00:00
|
|
|
$ git help add
|
|
|
|
adds things
|
|
|
|
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: git[EXE] add <PATH>...
|
2021-11-30 18:30:19 +00:00
|
|
|
|
2022-08-26 14:40:23 +00:00
|
|
|
Arguments:
|
2022-09-07 20:29:15 +00:00
|
|
|
<PATH>... Stuff to add
|
2021-11-30 18:30:19 +00:00
|
|
|
|
2022-08-26 14:40:23 +00:00
|
|
|
Options:
|
2022-09-07 20:29:15 +00:00
|
|
|
-h, --help Print help information
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2021-11-30 18:30:19 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
A basic argument:
|
2022-01-05 16:54:33 +00:00
|
|
|
```console
|
2021-11-30 18:30:19 +00:00
|
|
|
$ git add
|
|
|
|
? failed
|
|
|
|
adds things
|
|
|
|
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: git[EXE] add <PATH>...
|
2021-11-30 18:30:19 +00:00
|
|
|
|
2022-08-26 14:40:23 +00:00
|
|
|
Arguments:
|
2022-09-07 20:29:15 +00:00
|
|
|
<PATH>... Stuff to add
|
2021-11-30 18:30:19 +00:00
|
|
|
|
2022-08-26 14:40:23 +00:00
|
|
|
Options:
|
2022-09-07 20:29:15 +00:00
|
|
|
-h, --help Print help information
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2021-11-30 18:30:19 +00:00
|
|
|
$ git add Cargo.toml Cargo.lock
|
|
|
|
Adding ["Cargo.toml", "Cargo.lock"]
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2021-11-30 18:30:19 +00:00
|
|
|
```
|
|
|
|
|
2022-03-23 16:08:07 +00:00
|
|
|
Default subcommand:
|
|
|
|
```console
|
|
|
|
$ git stash -h
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: git[EXE] stash [OPTIONS]
|
|
|
|
git[EXE] stash <COMMAND>
|
2022-03-23 16:08:07 +00:00
|
|
|
|
2022-08-31 02:38:37 +00:00
|
|
|
Commands:
|
2022-09-07 20:29:15 +00:00
|
|
|
push
|
|
|
|
pop
|
|
|
|
apply
|
|
|
|
help Print this message or the help of the given subcommand(s)
|
2022-03-23 16:08:07 +00:00
|
|
|
|
2022-08-26 15:59:27 +00:00
|
|
|
Options:
|
2022-09-07 20:29:15 +00:00
|
|
|
-m, --message <MESSAGE>
|
|
|
|
-h, --help Print help information
|
2022-08-26 15:59:27 +00:00
|
|
|
|
2022-03-23 16:08:07 +00:00
|
|
|
$ git stash push -h
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: git[EXE] stash push [OPTIONS]
|
2022-03-23 16:08:07 +00:00
|
|
|
|
2022-08-26 14:40:23 +00:00
|
|
|
Options:
|
2022-09-07 20:29:15 +00:00
|
|
|
-m, --message <MESSAGE>
|
|
|
|
-h, --help Print help information
|
2022-03-23 16:08:07 +00:00
|
|
|
|
|
|
|
$ git stash pop -h
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: git[EXE] stash pop [STASH]
|
2022-03-23 16:08:07 +00:00
|
|
|
|
2022-08-26 14:40:23 +00:00
|
|
|
Arguments:
|
2022-09-07 20:29:15 +00:00
|
|
|
[STASH]
|
2022-03-23 16:08:07 +00:00
|
|
|
|
2022-08-26 14:40:23 +00:00
|
|
|
Options:
|
2022-09-07 20:29:15 +00:00
|
|
|
-h, --help Print help information
|
2022-03-23 16:08:07 +00:00
|
|
|
|
|
|
|
$ git stash -m "Prototype"
|
|
|
|
Pushing Some("Prototype")
|
|
|
|
|
|
|
|
$ git stash pop
|
|
|
|
Popping None
|
|
|
|
|
|
|
|
$ git stash push -m "Prototype"
|
|
|
|
Pushing Some("Prototype")
|
|
|
|
|
|
|
|
$ git stash pop
|
|
|
|
Popping None
|
|
|
|
|
|
|
|
```
|
|
|
|
|
2021-11-30 18:30:19 +00:00
|
|
|
External subcommands:
|
2022-01-05 16:54:33 +00:00
|
|
|
```console
|
2021-11-30 18:30:19 +00:00
|
|
|
$ git custom-tool arg1 --foo bar
|
|
|
|
Calling out to "custom-tool" with ["arg1", "--foo", "bar"]
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2021-11-30 18:30:19 +00:00
|
|
|
```
|
2022-09-07 16:19:28 +00:00
|
|
|
|
|
|
|
Last argument:
|
|
|
|
```console
|
|
|
|
$ git diff --help
|
|
|
|
Compare two commits
|
|
|
|
|
2022-10-01 01:33:36 +00:00
|
|
|
Usage: git[EXE] diff [OPTIONS] [COMMIT] [COMMIT] [-- <PATH>]
|
2022-09-07 16:19:28 +00:00
|
|
|
|
|
|
|
Arguments:
|
2022-09-07 20:29:15 +00:00
|
|
|
[COMMIT]
|
|
|
|
[COMMIT]
|
|
|
|
[PATH]
|
2022-09-07 16:19:28 +00:00
|
|
|
|
|
|
|
Options:
|
2022-10-01 01:33:36 +00:00
|
|
|
--color[=<WHEN>] [default: auto] [possible values: always, auto, never]
|
|
|
|
-h, --help Print help information
|
2022-09-07 16:19:28 +00:00
|
|
|
|
|
|
|
$ git diff
|
2022-10-01 01:33:36 +00:00
|
|
|
Diffing stage..worktree (color=auto)
|
2022-09-07 16:19:28 +00:00
|
|
|
|
|
|
|
$ git diff ./src
|
2022-10-01 01:33:36 +00:00
|
|
|
Diffing stage..worktree ./src (color=auto)
|
2022-09-07 16:19:28 +00:00
|
|
|
|
|
|
|
$ git diff HEAD ./src
|
2022-10-01 01:33:36 +00:00
|
|
|
Diffing HEAD..worktree ./src (color=auto)
|
2022-09-07 16:19:28 +00:00
|
|
|
|
|
|
|
$ git diff HEAD~~ -- HEAD
|
2022-10-01 01:33:36 +00:00
|
|
|
Diffing HEAD~~..worktree HEAD (color=auto)
|
|
|
|
|
|
|
|
$ git diff --color
|
|
|
|
Diffing stage..worktree (color=always)
|
|
|
|
|
|
|
|
$ git diff --color=never
|
|
|
|
Diffing stage..worktree (color=never)
|
2022-09-07 16:19:28 +00:00
|
|
|
|
|
|
|
```
|