0

Lets say I have a simple directory setup like this:

top-level/
   |-- .git/
   |     |-- modules/
   |          |-- level2
   |--level2/

Where top-level is a git repo and level2 is a submodule inside top-level. What I want is when I am inside level2 I want to be able to print my .git folder - which is: /home/.../top-level/.git/modules/level2 or ../.git/modules/level2 (I don't mind relative paths).

For this simple example I can hard code it - but I want a general way of finding this without having to write some script to search up folders until I find the .git directory.

I found: git rev-parse --show-toplevel which gets me "half way" but from there I still don't know the generalised path to my repo (i.e. I won't know how deep my submodule might be...

code_fodder
  • 15,263
  • 17
  • 90
  • 167

0 Answers0