githug (version 0.0.0.9000)

git_branch_delete: Delete a branch

Description

Delete an existing local branch. You won't be allowed to delete the branch you're on. Switch to another branch, then delete.

Usage

git_branch_delete(name, repo = ".")

Arguments

name
Name of the branch
repo
Path to a Git repo. If unspecified, current working directory is checked to see if it is or is inside a Git repo.

Details

Convenience wrapper around git2r::branch_delete().

Examples

Run this code
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