Pygithub: Fork a repo

Created on 18 Mar 2015  ·  2Comments  ·  Source: PyGithub/PyGithub

I couldn't find how to fork a repo, according to github APIs page can be used to do a fork,

thanks,

question

Most helpful comment

There is a method of user, create_fork,

g = Github(
    os.environ["GITHUB_USER"],
    os.environ["GITHUB_PASSWORD"]
)
github_user = g.get_user()
myfork = github_user.create_fork(repo)

All 2 comments

There is a method of user, create_fork,

g = Github(
    os.environ["GITHUB_USER"],
    os.environ["GITHUB_PASSWORD"]
)
github_user = g.get_user()
myfork = github_user.create_fork(repo)
Traceback (most recent call last):
  File "test.py", line 3, in <module>
    g = Github(os.environ["username"] ,os.environ["pw"])
  File "/usr/lib/python3.6/os.py", line 669, in __getitem__
    raise KeyError(key) from None
KeyError: 'username

and when i try to just basic login:

Traceback (most recent call last):
  File "test.py", line 5, in <module>
    myfork = github_user.create_fork("https://github.com/lyk2017-django/YilanTerbiyecisi")
  File "/usr/lib/python3.6/site-packages/github/AuthenticatedUser.py", line 452, in create_fork
    assert isinstance(repo, github.Repository.Repository), repo
AssertionError: https://github.com/lyk2017-django/YilanTerbiyecisi
Was this page helpful?
0 / 5 - 0 ratings