Is it possible to list the options of a Git command from the command line?
I am aware of git help <command>
and git <command> --help
, which provide the full documentation of a command with the complete list of its options. However, they redirect the user to a web page, leaving the command line.
Instead, I would like to know if there is a way to list the options of a command within the command line. I don't need the full documentation; just a list of the possible options will do.
To have the full option list of a Git command, you can type git <command> -h
. This will prompt Git to print:
For example:
git init -h
usage: git init [-q | --quiet] [--bare] [--template=<template-directory>]
[--separate-git-dir <git-dir>] [--object-format=<format>]
[--ref-format=<format>]
[-b <branch-name> | --initial-branch=<branch-name>]
[--shared[=<permissions>]] [<directory>]
--[no-]template <template-directory> directory from which templates will be used
--[no-]bare create a bare repository
--shared[=<permissions>] specify that the git repository is to be shared amongst several users
-q, --[no-]quiet be quiet
--[no-]separate-git-dir <gitdir> separate git dir from working tree
-b, --[no-]initial-branch <name> override the name of the initial branch
--[no-]object-format <hash> specify the hash algorithm to use
--[no-]ref-format <format> specify the reference format to use
Alternatively, you can enter a command followed by a double dash, and then type the TAB
key twice. Note that this approach only shows the options preceded by a double dash. Single dash options are excluded.
For example:
git init --<TAB><TAB>
--bare --object-format= --shared
--initial-branch= --quiet --template=
--no-... --ref-format=
--no-template --separate-git-dir=
Credits: thanks @joanis for your comment.