Just as we can create new files in a Github repo using PyGithub
, can we create directories/folders in a Github repo using PyGithub? I have been searching through the PyGithub docs but I haven't found anything substantial.
You can create directory using the same method as for when creating a file. But the catch is to create a file inside directory since Git tracks only folders which have files inside 1.
>>> repo = g.get_repo("PyGithub/PyGithub")
>>> repo.create_file("example/test.txt", "test message", "content_of_file", branch="test")
{'content': ContentFile(path="example/test.txt"), 'commit': Commit(sha="5b584cf6d32d960bb7bee8ce94f161d939aec377")}