4

As the documentation suggests, calling create_file on a github.Repository.Repository object should create a file but I am getting github.GithubException.UnknownObjectException.

My code is like this:

`repo.create_file('filename', 'commitmessage', 'content')`

What am I doing wrong?

Abhishek Kumar
  • 298
  • 4
  • 10

1 Answers1

2

It seems that you need to start the filename with a slash /. I've tried the following command, and it worked:

In [12]: repo.create_file('/filename', 'commitmessage', 'content')
Out[12]:
{'commit': Commit(sha="201e0e5b91f7ec431d5b06cc47affff202e3de04"),
 'content': ContentFile(path="filename")}
J. P. Petersen
  • 4,871
  • 4
  • 33
  • 33