我正在尝试在Windows上使用GitPython 3.0.3推送到远程git repo。我这样做:
repo = Repo(config['gitRepo'])
repo.git.add(A=True)
repo.index.commit("test")
with repo.git.custom_environment(GIT_SSH='F:\\nf\\rr.bat'):
repo.remotes.origin.push()
rr.bat的内容是:
ssh -p 8022 -i C:\Users\zikasak\.ssh\id_rsa -oIdentitiesOnly=yes -oStrictHostKeyChecking=no -oUserKnownHostsFile=C:\Users\zikasak\.ssh\known_hosts "$@"
但是我收到此错误消息:
Cmd('git') failed due to: exit code(128)
cmdline: git push --porcelain origin
stderr: 'fatal: protocol error: bad line length character: ?
F:
Pseudo-terminal will not be allocated because stdin is not a terminal.
Permission denied, please try again.
Permission denied, please try again.
$@: Permission denied (password,publickey).'
repo = Repo(config['gitRepo'])
repo.git.add(A=True)
repo.index.commit("test")
ssh_cmd = '''ssh -p 8022 -i C:\Users\zikasak\.ssh\id_rsa -oIdentitiesOnly=yes -oStrictHostKeyChecking=no -oUserKnownHostsFile=C:\Users\zikasak\.ssh\known_hosts "$@"'''
with repo.git.custom_environment(GIT_SSH=ssh_cmd):
repo.remotes.origin.push()