i: The index (integer or logical) of the tree object to extract. If negative values, all elements except those indicated are selected. A character vector to match against the names of objects to extract.
Returns
Git object
Examples
## Not run:##' Initialize a temporary repositorypath <- tempfile(pattern="git2r-")dir.create(path)dir.create(file.path(path,"subfolder"))repo <- init(path)##' Create a userconfig(repo, user.name ="Alice", user.email ="alice@example.org")##' Create three files and commitwriteLines("First file", file.path(path,"example-1.txt"))writeLines("Second file", file.path(path,"subfolder/example-2.txt"))writeLines("Third file", file.path(path,"example-3.txt"))add(repo, c("example-1.txt","subfolder/example-2.txt","example-3.txt"))new_commit <- commit(repo,"Commit message")##' Pick a tree in the repositorytree_object <- tree(new_commit)##' Display treetree_object
##' Select item by nametree_object["example-1.txt"]##' Select first item in treetree_object[1]##' Select first three items in treetree_object[1:3]##' Select all blobs in treetree_object[vapply(as(tree_object,'list'), is_blob, logical(1))]## End(Not run)