1

I am using PyPi to clone a github repository, however it a private repo. So I also need to authorise it with my token. I am unable to find any example of how to pass token with the clone request.

import git
git.Git('/local/file/path').clone('git@github.com:sample-repo.git', token=(mytoken))

This gives an error

"GitCommandError: Cmd('git') failed due to: exit code(129)" cmdline: git clone --token=mytoken git@github.com:sample-repo.git stderr: 'error: unknown option token=mytoken'

It works fine without the token when I try to clone a public repository. So the only issue here is how to pass the token to the above request. Is that possible or is there any other way to authorise git clone in a python script? My objective here is to automate a process to clone a github repository, generate some files using some API calls, add and commit those files to the repository, all within the same python script.

Saurav Ganguli
  • 396
  • 3
  • 18

1 Answers1

0

Thanks to the comments, I was able to clone my repository using the https url instead of the ssh url and it worked without the need for token.

import git
git.Git('/local/file/path').clone('https://github.com/sample-repo')
Saurav Ganguli
  • 396
  • 3
  • 18