curl --location --request POST 'https://api.github.com/repos///git/trees' \
--header 'Content-Type: application/json' \
--data-raw '{
"base_tree": "9fb037999f264ba9a7fc6274d15fa3ae2ab98312",
"tree": [
{
"mode": "100644",
"path": "file.rb",
"sha": "44b4fc6d56897b048c772eb4087f854f46256132",
"type": "blob"
}
]
}'
{
"sha": "string",
"tree": [
{
"mode": "100644",
"path": "file.rb",
"properties": {
"mode": {
"type": "string"
},
"path": {
"type": "string"
},
"sha": {
"type": "string"
},
"size": {
"type": "integer"
},
"type": {
"type": "string"
},
"url": {
"type": "string"
}
},
"required": [
"path",
"mode",
"type",
"sha",
"url",
"size"
],
"sha": "44b4fc6d56897b048c772eb4087f854f46256132",
"size": 30,
"type": "blob",
"url": "https://api.github.com/repos/octocat/Hello-World/git/blobs/44b4fc6d56897b048c772eb4087f854f46256132"
}
],
"truncated": true,
"url": "http://example.com"
}
Authorization: Bearer ********************
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.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.path
, mode
, type
, and sha
) specifying a tree structure.tree.sha
.tree.sha
or content
to specify the contents of the entry. Using both tree.sha
and content
will return an error.100644
for file (blob), 100755
for executable (blob), 040000
for subdirectory (tree), 160000
for submodule (commit), or 120000
for a blob that specifies the path of a symlink.tree.sha
. If the value is null
then the file will be deleted.tree.sha
or content
to specify the contents of the entry. Using both tree.sha
and content
will return an error.blob
, tree
, or commit
.【GitHub】API开发者 微信交流群
用微信扫右侧二维码,加入【GitHub】API开发者 交流群,互助沟通