The function recursively walks through directories until it finds a ".git" folder or reaches the root directory.
The function recursively walks through directories until it finds a ".git" folder or reaches the root directory.