Git rev-parse: Difference between revisions
Jump to navigation
Jump to search
Line 19: | Line 19: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
If inside the root of the main work tree, return: | If inside the root of the main work tree, return the relative path of $GIT_DIR: | ||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
.git | .git | ||
</syntaxhighlight> | </syntaxhighlight> | ||
If inside of a subdirectory of the main work tree, return the absolute path of | If inside of a subdirectory of the main work tree, return the absolute path of $GIT_DIR: | ||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
/Users/someuser/my-repo/.git | /Users/someuser/my-repo/.git |
Revision as of 04:38, 16 July 2020
Internal
Overview
Currently Checked Out Branch
Return the currently checked out branch in the current work tree:
git rev-parse --abbrev-ref HEAD
Other Options
--git-dir
git rev-parse --git-dir
If inside the root of the main work tree, return the relative path of $GIT_DIR:
.git
If inside of a subdirectory of the main work tree, return the absolute path of $GIT_DIR:
/Users/someuser/my-repo/.git
If inside the root of a linked work tree, return the absolute path of the linked tree private subdirectory in the $GIT_DIR of the repository (main work tree):
/Users/someuser/my-repo/.git/worktrees/my-linked-tree
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.
--is-inside-work-tree
Returns true if inside a working tree, including the main working tree.