Git: get path to current directory, relative to repo root

I saw this question that tells how to get the path to a specific file relative to the root of the git repository. But now I want to get the path to the current directory, and not to a specific file. If i use

git ls-tree --full-name --name-only HEAD . 

I get a list of all the files in the directory.

Is it possible?

+7
git bash
source share
2 answers

What about:

 $ git rev-parse --show-prefix 

From man git-rev-parse :

 --show-prefix When the command is invoked from a subdirectory, show the path of the current directory relative to the top-level directory. 
+16
source share
 #git ls-files --full-name | xargs -L1 dirname | sort -u 

Use git rev-parse --show-prefix above, awesome

-2
source share

All Articles