githug (version 0.0.0.9000)

git_stage: Stage changes for the next commit.

Description

Stage changes to files in preparation for a commit. In an interactive session, you'll get the chance to "just stage everything: Y/N?", if you haven't pre-staged or specified any paths. To pre-authorize the staging of all current file additions, deletions, and modifications, use git_stage(all = TRUE).

Usage

git_stage(..., all = FALSE, force = FALSE, repo = ".")
git_add(..., all = FALSE, force = FALSE, repo = ".")

Arguments

...
One or more paths or shell glob patterns that will be matched against files in the repo's working directory. Paths that match will be added to the set of changes staged for the next commit.
all
Logical, consulted if no paths are given. If TRUE, pre-authorizes the staging of all new files, file deletions, and file modifications. Emulates git add -A, which is equivalent to git add .; git add -u.
force
Logical, defaults to FALSE. Value TRUE is required if any of the to-be-staged paths are currently ignored.
repo
Path to a Git repo. If unspecified, current working directory is checked to see if it is or is inside a Git repo.

Value

nothing

Details

git_add() and git_stage() are aliases for each other, so use what feels most natural, i.e. "add" a file to the repo and "stage" modifications. These are convenience wrappers around git2r::add().

Examples

Run this code
repo <- git_init(tempfile("githug-"))
owd <- setwd(repo)
write("Are these girls real smart or real real lucky?", "max.txt")
write("You get what you settle for.", "louise.txt")
git_status()
## try this interactively and accept the proposed auto-staging
# git_add()
git_add("max.txt", "louise.txt")
git_status()
write("If done properly armed robbery doesn't have to be a totally unpleasant experience.",
      "jd.txt")
write("Is he your husband or your father?", "louise.txt", append = TRUE)
git_status()
git_stage(all = TRUE)
git_status()
git_commit(message = "Brains'll only get you so far and luck always runs out.")
git_status()
setwd(owd)

Run the code above in your browser using DataCamp Workspace