githug (version 0.0.0.9000)

git_commit: Make a commit

Description

Write file changes to the repository. If there are staged changes, the simple call git_commit(message = "my message") makes a commit. If nothing's staged and it's an interactive session, you'll get an offer to "just stage & commit everything: Y/N?". To explicitly authorize "stage and commit" for all current file additions, deletions, and modifications, use git_commit(all = TRUE), which emulates git add -A && git commit. In an interactive session, you will also get the chance to enter a missing commit message.

Usage

git_commit(..., all = FALSE, force = FALSE, message = character(), 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.
message
The commit message. Required. If not supplied, user will get a chance to provide the message in an interactive session.
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

SHA of the commit. The when attribute holds the commit time as POSIXct. An excerpt of the commit message is in the msg_start attribute.

Details

Convenience wrapper around git2r::commit() and, possibly, git_stage().

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()
git_commit(all = TRUE,
           message = "Brains'll only get you so far and luck always runs out.")
write("If done properly armed robbery doesn't have to be a totally unpleasant experience.",
      "jd.txt")
git_status()
git_commit("jd.txt", message = "J.D. is charming")
setwd(owd)

Run the code above in your browser using DataCamp Workspace