Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 315 Bytes

File metadata and controls

17 lines (12 loc) · 315 Bytes

Git top level directory using rev-parse

We want a program to be able to discover its own git top-level directory.

Our convention: create a function git_top_dir().

git_top_dir(){ 
    git rev-parse --show-toplevel
}

If you prefer one line:

GIT_TOP_DIR="$(git rev-parse --show-toplevel)"