I am attempting to write a python script that will run through a specified directory and update all local git repositories in the directory using GitPython. Everything I've written up to this point works and accomplishes the goal, but only if the repository is public.
If it's a private repository, which requires an authorized token, there does not seem to be any way to pull the repository by feeding a token to the function.
Current code:
import git
try:
local_directory = '/usr/share/git_repository' # Change me
git.cmd.Git(local_directory).pull()
print("Success! %s is now up to date" % directory)
except git.exc.GitCommandError as e:
if "Permission denied" in e.stderr:
print("DOH! You don't have permission!")
else "Something else went horribly wrong that is totally unrelated to this question."
Has anyone else encountered this problem that knows any way to feed a personal token into this or any other function in GitPython? I'm not finding anything in the documentation.