Use the REST API to read and write raw Git objects to your Git database on GitHub and to list and update your references (branch heads and tags).
OverviewThis basically allows you to reimplement a lot of Git functionality with the REST API - by creating raw objects directly into the database and updating branch references you could technically do just about anything that Git can do without having Git installed.
The REST API will return a 409 Conflict
if the Git repository is empty or unavailable. An unavailable repository typically means GitHub is in the process of creating the repository. For an empty repository, you can use the PUT /repos/{owner}/{repo}/contents/{path}
REST API endpoint to create content and initialize the repository so you can use the API to manage the Git database. Contact us through the GitHub Support portal if this response status persists.
For more information on the Git object database, please read the Git Internals chapter of the Pro Git book.
As an example, if you wanted to commit a change to a file in your repository, you would:
It might seem complex, but it's actually pretty simple when you understand the model and it opens up a ton of things you could potentially do with the API.
Checking mergeability of pull requestsA consuming API needs to explicitly request a pull request to create a test merge commit. A test merge commit is created when you view the pull request in the UI and the "Merge" button is displayed, or when you get, create, or edit a pull request using the REST API. Without this request, the merge
Git refs will fall out of date until the next time someone views the pull request.
If you are currently using polling methods that produce outdated merge
Git refs, then GitHub recommends using the following steps to get the latest changes from the default branch:
GET /repos/{owner}/{repo}/pulls/{pull_number}
to start a background job for creating the merge commit candidate.GET /repos/{owner}/{repo}/pulls/{pull_number}
to see if the mergeable
attribute is true
or false
. You can use Git directly or GET /repos/{owner}/{repo}/git/refs/{ref}
for updates to merge
Git refs only after performing the previous steps.RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4