repo <- git_init(tempfile("githug-branches-"))
owd <- setwd(repo)
## commit so that master branch exists
writeLines("Well, we're not in the middle of nowhere...", "nowhere.txt")
git_commit("nowhere.txt", message = "... but we can see it from here.")
## create a branch off of master
git_branch_create("doomed")
git_branch_list()
## switch to doomed branch
git_switch("doomed")
git_branch()
## Not run:
# ## try -- and fail -- to delete doomed branch
# git_branch_delete("doomed")
# ## End(Not run)
## switch back to master
git_switch()
## delete the new branch
git_branch_delete("doomed")
git_branch_list()
setwd(owd)
Run the code above in your browser using DataCamp Workspace