Search notes:

working tree [git]

The tree of actual checked out files.
The working tree normally contains the contents of the HEAD commit's tree, plus any local changes that were made but not yet committed.
A working tree is associated with exactly one branch.

Clean working tree

A working tree is clean, if it corresponds to the revision refrenced by the current head.
Conversely, the tree is dirty if it contains modifications not committed to the current branch.

Determine interesting directories

git rev-parse has some command line options which allow to determine interesting directories when executed from within a working directory.
Initialize a new repository for the demonstration:
git init --quiet  repo
cd                repo
Github repository about-git, path: /working-tree/determine-directories/create-repo.ps1
Create directory, a subdirectory ind descend into it:
$null = mkdir dir
$null = mkdir dir/subdir

cd            dir/subdir
Github repository about-git, path: /working-tree/determine-directories/create-directories.ps1
Show the absolute path to the top level directory:
git rev-parse --show-toplevel
Github repository about-git, path: /working-tree/determine-directories/top-level-absolute.ps1
Show the relative path to the top level directory with a trailing slash (in this case: ../../):
git rev-parse --show-cdup
Github repository about-git, path: /working-tree/determine-directories/top-level-relative.ps1
Show the relative path from the top level directory to the current directory with a trailing slash (in this case dir/subdir/):
git rev-parse --show-prefix
Github repository about-git, path: /working-tree/determine-directories/cur-dir-relative-to-top-level.ps1
Show the absolute location of the git dir:
git rev-parse --git-dir
Github repository about-git, path: /working-tree/determine-directories/git-dir.ps1

See also

The --work-tree command line option.
.git/worktrees
working directory
checkout, git checkout-index, git clean, git diff, git worktree, status, git rm, git ls-files

Index