Back
Mercurial has a way of printing the root directory (that contains .hg) via
hg root
Is there something equivalent in git to get the directory that contains the .git directory?
Yes, there is a way in git to get the directory that contains the .git directory use the following command
git rev-parse --show-toplevel
Note: In a submodule, this will display the root directory of the submodule and not the parent repository.
If you are in a submodule folder, with Git >=2.13, use:
git rev-parse --show-superproject-working-tree
For older versions, git refer: https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---show-superproject-working-tree
31k questions
32.8k answers
501 comments
693 users