I found this a bit like the way git works in the shell.
import os from git import Git, Repo global_git = Git() global_git.update_environment( **{ k: os.environ[k] for k in os.environ if k.startswith('SSH') } )
This is basically copying SSH environment variables to GitPython "shadow" environment. Then it uses the SSH-AGENT general authentication mechanisms, so you donβt have to worry about specifying exactly which key it is.
For a faster alternative that carries a lot of nonsense, but it works too:
import os from git import Git global_git = Git() global_git.update_environment(**os.environ)
This reflects your entire environment, more like a subshell in bash.
In any case, any future call to create a repo or clone takes away the "customized" environment and performs standard git authentication.
No scripts required.
source share