Create a tree

POST {{baseUrl}}/repos/:owner/:repo/git/trees

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](https://developer.github.com/v3/git/commits/#create-a-commit) and [Update a reference](https://developer.github.com/v3/git/refs/#update-a-reference).

Request Body

{"tree"=>[{"path"=>"<string>", "mode"=>"<string>", "type"=>"<string>", "sha"=>"<string>", "content"=>"<string>"}, {"path"=>"<string>", "mode"=>"<string>", "type"=>"<string>", "sha"=>"<string>", "content"=>"<string>"}], "base_tree"=>"<string>"}

HEADERS

KeyDatatypeRequiredDescription
Content-Typestring

RESPONSES

status: Created

{&quot;sha&quot;:&quot;cd8274d15fa3ae2ab983129fb037999f264ba9a7&quot;,&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/trees/cd8274d15fa3ae2ab983129fb037999f264ba9a7&quot;,&quot;tree&quot;:[{&quot;path&quot;:&quot;file.rb&quot;,&quot;mode&quot;:&quot;100644&quot;,&quot;type&quot;:&quot;blob&quot;,&quot;size&quot;:132,&quot;sha&quot;:&quot;7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b&quot;,&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/git/blobs/7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b&quot;}],&quot;truncated&quot;:true}