Git rev-parse: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 4: Line 4:
=Overview=
=Overview=


=Return the Value of $GIT_DIR=
=Value of $GIT_DIR=


<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
Line 17: Line 17:
</syntaxhighlight>
</syntaxhighlight>
to stderr and return 128 return code if not in a git work area.
to stderr and return 128 return code if not in a git work area.
=Currently Checked Out Branch=
Return the currently checked out branch in the current work tree:
<syntaxhighlight lang='bash'>
git rev-parse --abbrev-ref HEAD
</syntaxhighlight>

Revision as of 03:56, 16 July 2020

Internal

Overview

Value of $GIT_DIR

git rev-parse --git-dir

If inside a git work area, return the relative path of $GIT_DIR (.git in the root of the work area, absolute path from other location).

Sends

"fatal: not a git repository (or any of the parent directories): .git"

to stderr and return 128 return code if not in a git work area.

Currently Checked Out Branch

Return the currently checked out branch in the current work tree:

git rev-parse --abbrev-ref HEAD