1% Generated by roxygen2: do not edit by hand 2% Please edit documentation in R/commit.R 3\name{git_commit} 4\alias{git_commit} 5\alias{git_commit_all} 6\alias{git_commit_info} 7\alias{git_commit_id} 8\alias{git_commit_descendant_of} 9\alias{git_add} 10\alias{git_rm} 11\alias{git_status} 12\alias{git_conflicts} 13\alias{git_ls} 14\alias{git_log} 15\alias{git_stat_files} 16\title{Stage and commit changes} 17\usage{ 18git_commit(message, author = NULL, committer = NULL, repo = ".") 19 20git_commit_all(message, author = NULL, committer = NULL, repo = ".") 21 22git_commit_info(ref = "HEAD", repo = ".") 23 24git_commit_id(ref = "HEAD", repo = ".") 25 26git_commit_descendant_of(ancestor, ref = "HEAD", repo = ".") 27 28git_add(files, force = FALSE, repo = ".") 29 30git_rm(files, repo = ".") 31 32git_status(staged = NULL, repo = ".") 33 34git_conflicts(repo = ".") 35 36git_ls(repo = ".") 37 38git_log(ref = "HEAD", max = 100, repo = ".") 39 40git_stat_files(files, ref = "HEAD", repo = ".") 41} 42\arguments{ 43\item{message}{a commit message} 44 45\item{author}{A \link{git_signature} value, default is \code{\link[=git_signature_default]{git_signature_default()}}.} 46 47\item{committer}{A \link{git_signature} value, default is same as \code{author}} 48 49\item{repo}{The path to the git repository. If the directory is not a 50repository, parent directories are considered (see \link{git_find}). To disable 51this search, provide the filepath protected with \code{\link[=I]{I()}}. When using this 52parameter, always explicitly call by name (i.e. \verb{repo = }) because future 53versions of gert may have additional parameters.} 54 55\item{ref}{revision string with a branch/tag/commit value} 56 57\item{ancestor}{a reference to a potential ancestor commit} 58 59\item{files}{vector of paths relative to the git root directory. 60Use \code{"."} to stage all changed files.} 61 62\item{force}{add files even if in gitignore} 63 64\item{staged}{return only staged (TRUE) or unstaged files (FALSE). 65Use \code{NULL} or \code{NA} to show both (default).} 66 67\item{max}{lookup at most latest n parent commits} 68} 69\value{ 70\itemize{ 71\item \code{git_status()}, \code{git_ls()}: A data frame with one row per file 72\item \code{git_log()}: A data frame with one row per commit 73\item \code{git_commit()}, \code{git_commit_all()}: A SHA 74} 75} 76\description{ 77To commit changes, start by \emph{staging} the files to be included in the commit 78using \code{git_add()} or \code{git_rm()}. Use \code{git_status()} to see an overview of 79staged and unstaged changes, and finally \code{git_commit()} creates a new commit 80with currently staged files. 81 82\code{git_commit_all()} is a convenience function that automatically stages and 83commits all modified files. Note that \code{git_commit_all()} does \strong{not} add 84new, untracked files to the repository. You need to make an explicit call to 85\code{git_add()} to start tracking new files. 86 87\code{git_log()} shows the most recent commits and \code{git_ls()} lists all the files 88that are being tracked in the repository. 89} 90\examples{ 91oldwd <- getwd() 92repo <- file.path(tempdir(), "myrepo") 93git_init(repo) 94setwd(repo) 95 96# Set a user if no default 97if(!user_is_configured()){ 98 git_config_set("user.name", "Jerry") 99 git_config_set("user.email", "jerry@gmail.com") 100} 101 102writeLines(letters[1:6], "alphabet.txt") 103git_status() 104 105git_add("alphabet.txt") 106git_status() 107 108git_commit("Start alphabet file") 109git_status() 110 111git_ls() 112 113git_log() 114 115cat(letters[7:9], file = "alphabet.txt", sep = "\n", append = TRUE) 116git_status() 117 118git_commit_all("Add more letters") 119 120# cleanup 121setwd(oldwd) 122unlink(repo, recursive = TRUE) 123} 124\seealso{ 125Other git: 126\code{\link{git_archive}}, 127\code{\link{git_branch}()}, 128\code{\link{git_config}()}, 129\code{\link{git_diff}()}, 130\code{\link{git_fetch}()}, 131\code{\link{git_merge}()}, 132\code{\link{git_rebase}()}, 133\code{\link{git_remote}}, 134\code{\link{git_repo}}, 135\code{\link{git_signature}()}, 136\code{\link{git_stash}}, 137\code{\link{git_tag}} 138} 139\concept{git} 140