LinuxCommandLibrary

git-root

Print the root directory of the current Git repository.

TLDR

Print the absolute path of the current Git repository

$ git root
copy


Print the current working directory relative to the root of the current Git repository
$ git root --relative
copy

SYNOPSIS

git root OPTIONS

DESCRIPTION

print the path for the root directory of git repo

OPTIONS

-r, --relative

show the relative path from root directory to current directory

EXAMPLES

$ cd  . . ./git-extras/bin
$ git root -r
bin/
$ git root
/home/ . . ./git-extras
$ cd `git root`
$ pwd
/home/ . . ./git-extras
# then we can
$ git add . && git commit

REPORTING BUGS

<https://github.com/tj/git-extras/issues>

SEE ALSO

<https://github.com/tj/git-extras>

AUTHOR

Written by spacewander <spacewanderlzx@gmail.com>

Copied to clipboard