Description Usage Arguments git_branch git_branch_current git_branch_list Examples
Report which branch you're currently on or list all local and/or remote branches in the repository.
1 2 3 4 5 | git_branch(where = NULL, repo = ".")
git_branch_current(repo = ".")
git_branch_list(where = c("local", "all", "remote"), repo = ".")
|
where |
Which branches to list: |
repo |
Path to a Git repo. If unspecified, current working directory is checked to see if it is or is inside a Git repo. |
If called with no arguments, or with only the repo
argument,
git_branch()
reports the name of the current branch. This is
equivalent to calling git_branch_current()
directly.
If the where
argument is given, its value is passed through to
git_branch_list()
.
git_branch()
tells which branch you're currently on.
git_branch_list()
returns a data frame of information provided by
git2r::branches()
.
How it corresponds to command line Git:
git_branch_list()
is like git branch
. Lists local
branches.
git_branch_list(where = "all")
is like git branch -a
.
Lists all branches, local and remote.
git_branch_list(where = "remote")
is like git branch
-r
. Lists remote branches.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | repo <- git_init(tempfile("githug-branches-"))
owd <- setwd(repo)
## no commits --> no branches
git_branch()
git_branch_list()
## commit and ... now we have master
write("Well, we're not in the middle of nowhere,", "nowhere.txt")
git_commit(all = TRUE, message = "1ouise: not in the middle of nowhere")
git_branch()
git_branch_list()
## make a new commit then checkout initial commit, thereby detaching HEAD
write("but we can see it from here.", "nowhere.txt", append = TRUE)
git_commit(all = TRUE, message = "louise: but can see it")
## TODO: come back and make this nicer when more functions exist
init_commit <- as.git_commit(git_revision("HEAD^"))
git2r::checkout(init_commit)
git_branch()
git_branch_list()
setwd(owd)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.