branch_create(commit = last_commit(), name =NULL, force =FALSE)
Arguments
commit: Commit to which the branch should point. The default is to use the last_commit() function to determine the commit to which the branch should point.
name: Name for the branch
force: Overwrite existing branch. Default = FALSE
Returns
invisible git_branch object
Examples
## Not run:## Initialize a temporary repositorypath <- tempfile(pattern="git2r-")dir.create(path)repo <- init(path)## Create a user and commit a fileconfig(repo, user.name ="Alice", user.email ="alice@example.org")lines <-"Hello world!"writeLines(lines, file.path(path,"example.txt"))add(repo,"example.txt")commit_1 <- commit(repo,"First commit message")## Create a branchbranch_1 <- branch_create(commit_1, name ="test-branch")## Add one more commitlines <- c("Hello world!","HELLO WORLD!")writeLines(lines, file.path(path,"example.txt"))add(repo,"example.txt")commit_2 <- commit(repo,"Another commit message")## Create a branch with the same name should failtry(branch_create(commit_2, name ="test-branch"),TRUE)## Force itbranch_2 <- branch_create(commit_2, name ="test-branch", force =TRUE)## End(Not run)