git_commit: Make a commit

Description Usage Arguments Details Value Examples

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

1
2
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.

Details

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

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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)

jennybc/githug documentation built on May 19, 2019, 5:05 a.m.