Search notes:

git rev-parse

Pick out and massage parameters.

Get a repository's latest commit ids

Latest commit id:
git rev-parse @
git rev-parse @~0
git rev-parse HEAD
2nd latest commit id:
git rev-parse @^
git rev-parse @~1
git rev-parse HEAD^1
3rd latest commit id:
git rev-parse @^^
git rev-parse @~2
git rev-parse HEAD^1^1

Determine interesting directories of a working directory

git rev-parse allows to determine some interesting directories of a working tree.

The .git directory

The .git directory can be determined as follows
git rev-parse --git-dir
git rev-parse --absolute-git-dir

The top level directory

git rev-parse --show-cdup
Returns »nothing« if already in the top level directory of a git repository. Otherwise, returns a relative path (typically something like ../../).

The objects directory

The objects directory can be found like so:
git rev-parse --git-path objects

See also

git commands

Index