2

It is possible to add (commit) a new file to a Git repository in a browser according to GitHub documentation.

I want to do the same in my Java application.

Where can I find GitHub API documentation for the API call that is being used here?

Here are the request data I found using Firefox:

Screenshot

Screenshot

Glory to Russia
  • 17,289
  • 56
  • 182
  • 325

2 Answers2

1

For creating or updating file contents in a GitHub repo, you can use the below GitHub v3 API

PUT /repos/{owner}/{repo}/contents/{path}

The documentation of the above API can be found here.

Madhu Bhat
  • 13,559
  • 2
  • 38
  • 54
0
curl -X PUT -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"message":"Commit message","content":"<file_content>","branch":"<branch_name>"}' https://api.github.com/repos/{owner}/{repo}/contents/{path}
Erçin Dedeoğlu
  • 4,950
  • 4
  • 49
  • 69