general recursive git function