开发者

GitHub API - write to repo

I looked all documentatio开发者_如何学Pythonn, but it doesn't answer my question.

There is a way to write to a repo (upload a file)? Something like create a folder, and upload a readme.md


Folders do not need to be created as they only exists implicitly in git. Meaning that if you have a file with path folder/file.txt then your git client knows to create a folder called "folder" where the file "file.txt" is saved, but to git it is just a file with the name "folder/file.txt"

You can use: PUT /repos/{owner}/{repo}/contents/{path} where {path} is the folder path and file name, and put message and file content (Base64 encoded) in the body.

When you are updating a file you also need to indicate which version in the git history of the file you want to update. Read more here https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜