Description
Hey all,
I am having an issue with using the custom_environment parameter.
This is on a Windows 10 machine.
Basically this will not work, returning the error (see under code)
import git
from git import Repo
from git import Git
git_ssh_cmd = 'ssh -i gpt_key'
with Git().custom_environment(GIT_SSH_COMMAND=git_ssh_cmd):
Repo.clone_from('[email protected]:<private git>.git', 'python_test_cloning')
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.Please make sure you have the correct access rights
and the repository exists.
However setting the env variable in the Repo.clone_from command works fine:
Repo.clone_from('[email protected]:<private git>.git', 'python_test_cloning', env={"GIT_SSH_COMMAND": 'ssh -i gpt_key'})
I need to be able to use the ssh key for operation other than cloning, so I need to be able to set up the local environment purely via the python interface. This also fails for reference (when I did sucessfully clone).
repo = git.Repo("python_test_cloning")
with repo.git.custom_environment(GIT_SSH_COMMAND='ssh -i gpt_key'):
for remote in repo.remotes:
remote.fetch()
with error:
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
cmdline: git fetch -v origin
stderr: 'fatal: Could not read from remote repository.Please make sure you have the correct access rights
and the repository exists.'
Any ideas of why this is not working and how to fix it?
Remember that this is Windows 10.
Thanks,
CaptainJL