REST-API-Endpunkte für Git-Strukturen
Verwende die REST-API, um mit Strukturobjekten in deiner Git-Datenbank in GitHub zu interagieren.
Informationen zu Git-Strukturen
Ein Git-Strukturobjekt erstellt die Hierarchie zwischen Dateien in einem Git-Repository. Du kannst das Git-Strukturobjekt verwenden, um die Beziehung zwischen Verzeichnissen und den darin enthaltenen Dateien zu erstellen. Diese Endpunkte ermöglichen dir das Lesen und Schreiben von Strukturobjekten in deine Git-Datenbank auf GitHub.
Create a tree
The tree creation API accepts nested entries. If you specify both a tree and a nested path modifying that tree, this endpoint will overwrite the contents of the tree with the new path contents, and create a new tree structure.
If you use this endpoint to add, delete, or modify the file contents in a tree, you will need to commit the tree and then update a branch to point to the commit. For more information see "Create a commit" and "Update a reference."
Returns an error if you try to delete a file that does not exist.
Differenzierte Zugriffstoken für "Create a tree"
Dieser Endpunkt funktioniert mit den folgenden differenzierten Tokentypen.:
- GitHub-App-Benutzerzugriffstoken
- Zugriffstoken für GitHub App-Installation
- Differenzierte persönliche Zugriffstoken
Das differenzierte Token muss einen der folgenden Berechtigungssätze aufweisen.:
- "Contents" repository permissions (write)
Parameter für „Create a tree“
| Name, type, BESCHREIBUNG |
|---|
accept string Setting to |
| Name, type, BESCHREIBUNG |
|---|
owner string ErforderlichThe account owner of the repository. The name is not case sensitive. |
repo string ErforderlichThe name of the repository without the |
| Name, type, BESCHREIBUNG | ||||||
|---|---|---|---|---|---|---|
tree array of objects ErforderlichObjects (of | ||||||
Properties of |
| Name, type, BESCHREIBUNG |
|---|
path string The file referenced in the tree. |
mode string The file mode; one of Kann eine der Folgenden sein: |
type string Either Kann eine der Folgenden sein: |
sha string or null The SHA1 checksum ID of the object in the tree. Also called Note: Use either |
content string The content you want this file to have. GitHub will write this blob out and use that SHA for this entry. Use either this, or Note: Use either |
base_tree string The SHA1 of an existing Git tree object which will be used as the base for the new tree. If provided, a new Git tree object will be created from entries in the Git tree object pointed to by base_tree and entries defined in the tree parameter. Entries defined in the tree parameter will overwrite items from base_tree with the same path. If you're creating new changes on a branch, then normally you'd set base_tree to the SHA1 of the Git tree object of the current latest commit on the branch you're working on.
If not provided, GitHub will create a new Git tree object from only the entries defined in the tree parameter. If you create a new commit pointing to such a tree, then all files which were a part of the parent commit's tree and were not defined in the tree parameter will be listed as deleted by the new commit.
HTTP-Antwortstatuscodes für „Create a tree“
| Statuscode | BESCHREIBUNG |
|---|---|
201 | Created |
403 | Forbidden |
404 | Resource not found |
409 | Conflict |
422 | Validation failed, or the endpoint has been spammed. |