Currently Checked Out Branch
Return the currently checked out branch in the current work tree:
git rev-parse --abbrev-ref HEAD
See Getting the Current Git Branch for alternatives.
git rev-parse HEAD
git rev-parse --git-dir
If inside the root of the main work tree, return the relative path of $GIT_DIR:
If inside of a subdirectory of the main work tree, return the absolute path of $GIT_DIR:
If inside a linked work tree, either root or any of its subdirectories, return the absolute path of the linked tree private subdirectory in the $GIT_DIR of the repository (main work tree):
"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.
Returns true if inside a working tree, including the main working tree.
When the command is invoked from a subdirectory, show the path of the current directory relative to the top-level directory. Works for both main work tree and linked trees. When in the root of the directory, produces empty string.
Show the absolute path of the top-level directory.
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).