Is it possible to programmatically find the path to the .git directory including for submodules?
I'm trying to write a script that installs a git hook but I can't find a straightforward way to find the .git directory for the project. Ideally it should cover the following cases:
- In root directory of project
- In sub-directory of project
- In root directory of submodule within project
- In sub-directory of submodule within project
I could do all of this manually but I'd rather not parse the .git file of a submodule.
Edit: I'd be interested in a solution in python as well.