import contextlib import os import subprocess from datetime import datetime # performing git fsck(file system check) seems slower, so I mane this hack # still can be found on it's upstream or here : https://gist.github.com/neingeist/7d448e574e9da30b6bcd def git_directories(startdir): for dirpath, dirnames, _ in os.walk(startdir): if set(['info', 'objects', 'refs']).issubset(set(dirnames)): yield dirpath @contextlib.contextmanager def working_directory(directory): saved_cwd = os.getcwd() os.chdir(directory) yield os.chdir(saved_cwd) def remote_v(directory): file = open("config","r") for line in file : if ".git" in line: print(line) # add correct path for you - where you want to log your data with open('D:\git_log.txt', 'a') as logfile: #print(datetime.now()) logfile.write(directory+" -M- "+ str(datetime.now()) + " -M- "+line) for git_directory in git_directories('.'): with working_directory(git_directory): print('\n{} : '.format(os.getcwd())) remote_v(os.getcwd()) # it will produce some extra upstream location such as [lfs], [hooks], [and some submodule links] ''' result looks something like this : E:\gits\android-architecture-components\.git -M- 2020-06-23 11:19:09.463253 -M- url = https://github.com/maifeeulasad/android-architecture-components.git E:\gits\android-viewmodel-databinding\.git -M- 2020-06-23 11:19:09.613164 -M- url = https://github.com/maifeeulasad/android-viewmodel-databinding.git E:\gits\Android-Volume-Head\.git -M- 2020-06-23 11:19:09.820053 -M- url = https://github.com/maifeeulasad/Android-Volume-Head.git '''