- Personal Access
<token>
for<user>
with allrepo[...]
access (may need more permissions, depending on the commit) - The
<user>
having write/push access to the existing<branch>
of the intended<repo>
of<org|user>
- For creating new commits
- The base64 encoded file content
<base64content>
is required. - To update an existing file, the
<sha>
hash of the file that's being replaced on GitHub repo is required
- The base64 encoded file content
Creating commits with /contents
endpoint come with a limitation (as of APIv3) that it can only create/update a file. Updating multiple files (with a DIFF) doesn't seem to be possible very easily. The SHA sum is only required to update a single file with new contents, not for creating new file.
curl -X PUT -u <user>:<token> -d '{"message": "Commit Message", "branch": "<branch>", "content": "<base64content>", "sha": "<sha>"}' https://api.github.com/repos/<org|user>/<repo>/contents/<path>/<to>/<file.ext>
Creating pull request is relatively easier than creating commits. The "base"
branch is generally the upstream master
, and "head"
is the downstream (as username:feature-branch
) or working branch on the same repo (then only feature-branch
) but both are pushed on GitHub, not are on local system. The "body"
of the PR is optional.
curl -X POST -u <user>:<token> -d '{"title": "PR Title", "base": "master", "head": "feature-branch", "body": "Hello world!"}' https://api.github.com/repos/<org|user>/<repo>/pulls