Home Explore Blog CI



git

4th chunk of `Documentation/git-rev-parse.adoc`
8edf78e759e21c97ba6b7cd4a32d10702a49258bf879b72b0000000100000f7e
 defined. Otherwise show the path to
	the .git directory. The path shown, when relative, is
	relative to the current working directory.
+
If `$GIT_DIR` is not defined and the current directory
is not detected to lie in a Git repository or work tree
print a message to stderr and exit with nonzero status.

--git-common-dir::
	Show `$GIT_COMMON_DIR` if defined, else `$GIT_DIR`.

--resolve-git-dir <path>::
	Check if <path> is a valid repository or a gitfile that
	points at a valid repository, and print the location of the
	repository.  If <path> is a gitfile then the resolved path
	to the real repository is printed.

--git-path <path>::
	Resolve "$GIT_DIR/<path>" and takes other path relocation
	variables such as $GIT_OBJECT_DIRECTORY,
	$GIT_INDEX_FILE... into account. For example, if
	$GIT_OBJECT_DIRECTORY is set to /foo/bar then "git rev-parse
	--git-path objects/abc" returns /foo/bar/abc.

--show-toplevel::
	Show the (by default, absolute) path of the top-level directory
	of the working tree. If there is no working tree, report an error.

--show-superproject-working-tree::
	Show the absolute path of the root of the superproject's
	working tree (if exists) that uses the current repository as
	its submodule.  Outputs nothing if the current repository is
	not used as a submodule by any project.

--shared-index-path::
	Show the path to the shared index file in split index mode, or
	empty if not in split-index mode.

The following options are unaffected by `--path-format`:

--absolute-git-dir::
	Like `--git-dir`, but its output is always the canonicalized
	absolute path.

--is-inside-git-dir::
	When the current working directory is below the repository
	directory print "true", otherwise "false".

--is-inside-work-tree::
	When the current working directory is inside the work tree of the
	repository print "true", otherwise "false".

--is-bare-repository::
	When the repository is bare print "true", otherwise "false".

--is-shallow-repository::
	When the repository is shallow print "true", otherwise "false".

--show-cdup::
	When the command is invoked from a subdirectory, show the
	path of the top-level directory relative to the current
	directory (typically a sequence of "../", or an empty string).

--show-prefix::
	When the command is invoked from a subdirectory, show the
	path of the current directory relative to the top-level
	directory.

--show-object-format[=(storage|input|output)]::
	Show the object format (hash algorithm) used for the repository
	for storage inside the `.git` directory, input, or output. For
	input, multiple algorithms may be printed, space-separated.
	If not specified, the default is "storage".

--show-ref-format::
	Show the reference storage format used for the repository.


Other Options
~~~~~~~~~~~~~

--since=<datestring>::
--after=<datestring>::
	Parse the date string, and output the corresponding
	--max-age= parameter for 'git rev-list'.

--until=<datestring>::
--before=<datestring>::
	Parse the date string, and output the corresponding
	--min-age= parameter for 'git rev-list'.

<arg>...::
	Flags and parameters to be parsed.


include::revisions.adoc[]

PARSEOPT
--------

In `--parseopt` mode, 'git rev-parse' helps massaging options to bring to shell
scripts the same facilities C builtins have. It works as an option normalizer
(e.g. splits single switches aggregate values), a bit like `getopt(1)` does.

It takes on the standard input the specification of the options to parse and
understand, and echoes on the standard output a string suitable for `sh(1)` `eval`
to replace the arguments with normalized ones.  In case of error, it outputs
usage on the standard error stream, and exits with code 129.

Note: Make sure you quote the result when passing it to `eval`.  See
below for an example.

Input Format
~~~~~~~~~~~~

'git rev-parse --parseopt' input format is fully text based. It has two parts,
separated by a line that contains only `--`. The lines before the separator
(should

Title: Git Rev-Parse Command Options and Parseopt Mode
Summary
The git rev-parse command provides additional options for working with repository paths, object formats, and reference storage formats, as well as a parseopt mode for normalizing options and massaging input for shell scripts, allowing for standardized option parsing and processing.