knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-",
error = TRUE
)
The goal of githug is to wrap you in the warm embrace of Git 🤗, from the comfort of R.
This a reboot of an earlier effort, which lives on in branch first-draft
. That branch includes a function githug_init()
to connect a new or existing R project (usually a RStudio Project) to a newly created GitHub remote. Currently plodding my way back to that level of functionality.
You can install githug from github with:
# install.packages("devtools")
devtools::install_github("jennybc/githug")
Load dev version of the package. This will become library(githug)
.
#library(githug)
devtools::load_all(".")
Create a new Git repository and set that as working directory for the duration of this example.
repo <- git_init(tempfile("githug-example-"))
knitr::opts_knit$set(root.dir = repo)
Set (local) config variables for user and email. Create two files and inspect Git status.
git_config_local(user.name = "louise", user.email = "[email protected]")
write("Are these girls real smart or real real lucky?", "max.txt")
write("You get what you settle for.", "louise.txt")
git_status()
Commit with all = TRUE
to automatically accept all current changes. In interactive use, if all
is unspecified, you get an offer to just stage all current changes.
git_commit(all = TRUE,
message = "Brains'll only get you so far and luck always runs out.")
Add new file and commit it. Inspect commit history.
write("Did I hear somebody say \"Peaches\"?", "jimmy.txt")
git_commit("jimmy.txt", message = "That's the code word. I miss you, Peaches.")
git_history()
Uncommit, i.e. leave files as they are, but go back to parent of current commit.
git_uncommit(ask = FALSE)
git_history()
Verify files and staging are OK. Unstage a file.
git_status()
list.files()
git_unstage("jimmy.txt")
git_status()
See history.
Create and checkout a branch. In an interactive session, if create
is unspecified and branch does not exist, you are asked if you want to create the branch. Go back to master.
git_history()
git_branch()
git_switch("new_branch", create = TRUE)
git_branch()
git_switch()
git_branch_list()
fxn_table <-
"fxn,description
git_config(), Get and set Git configuration variables
git_init(), Create a new repository
git_status(), Get status of all files w/r/t Git
git_history(), Get commit history (a.k.a. the log)
git_stage(), Stage (changes to) a path for next commit
git_add(), Synonym for git_stage()
git_unstage(), Unstage (changes to) a path
git_commit(), Make a commit
git_uncommit(), Undo a Git commit but leave files alone
git_amend(), Re-do the most recent commit
git_file_rename(), Rename or move and file and stage it
git_mv(), Synonym for git_file_rename()
git_branch(), Report current branch or list all branches
git_switch(), Switch to another branch
git_branch_*(), \"Lower level functions to list, create, rename, delete, and checkout branches\"
git_revision(), Identify a specific commit
as.git_repository(), Open a Git repo in the style of the `git2r` package
as.git_commit(), Get a specific commit in the style of the `git2r` package
"
knitr::kable(read.csv(text = fxn_table))
to be replaced by a proper test coverage badge
Sys.time()
git2r::repository("~/rrr/githug0")
covr::package_coverage("~/rrr/githug0/")