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