GitPython and SSH Keys?

前端 未结 5 862
生来不讨喜
生来不讨喜 2020-12-14 02:23

How can I use GitPython along with specific SSH Keys?

The documentation isn\'t very thorough on that subject. The only thing I\'ve tried so far is Repo(path)

5条回答
  •  天命终不由人
    2020-12-14 02:41

    Following worked for me on gitpython==2.1.1

    import os
    from git import Repo
    from git import Git
    
    git_ssh_identity_file = os.path.expanduser('~/.ssh/id_rsa')
    git_ssh_cmd = 'ssh -i %s' % git_ssh_identity_file
    
    with Git().custom_environment(GIT_SSH_COMMAND=git_ssh_cmd):
         Repo.clone_from('git@....', '/path', branch='my-branch')
    

提交回复
热议问题