-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathgit_config.Rd
More file actions
101 lines (92 loc) · 3.23 KB
/
Copy pathgit_config.Rd
File metadata and controls
101 lines (92 loc) · 3.23 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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/config.R
\name{git_config}
\alias{git_config}
\alias{git_config_global}
\alias{git_config_set}
\alias{git_config_global_set}
\title{Get or set Git configuration}
\usage{
git_config(repo = ".")
git_config_global()
git_config_set(name, value, repo = ".")
git_config_global_set(name, value)
}
\arguments{
\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{name}{Name of the option to set}
\item{value}{Value to set. Must be a string, logical, number or \code{NULL} (to
unset).}
}
\value{
\itemize{
\item \code{git_config()}: a \code{data.frame} of the Git options "in force" in the context
of \code{repo}, one row per option. The \code{level} column reveals whether the
option is determined from global or local config.
\item \code{git_config_global()}: a \code{data.frame}, as for \code{git_config()}, except only
for global Git options.
\item \code{git_config_set()}, \code{git_config_global_set()}: The previous value of
\code{name} in local or global config, respectively. If this option was
previously unset, returns \code{NULL}. Returns invisibly.
}
}
\description{
Get or set Git options, as \verb{git config} does on the command line. \strong{Global}
settings affect all of a user's Git operations (\verb{git config --global}),
whereas \strong{local} settings are scoped to a specific repository (\verb{git config --local}). When both exist, local options always win. Four functions address
the four possible combinations of getting vs setting and global vs. local.\tabular{lll}{
\tab \strong{local} \tab \strong{global} \cr
get \tab \code{git_config()} \tab \code{git_config_global()} \cr
set \tab \code{git_config_set()} \tab \code{git_config_global_set()} \cr
}
}
\note{
All entries in the \code{name} column are automatically normalised to
lowercase (see
\url{https://libgit2.org/libgit2/#HEAD/type/git_config_entry} for details).
}
\examples{
# Set and inspect a local, custom Git option
r <- file.path(tempdir(), "gert-demo")
git_init(r)
previous <- git_config_set("aaa.bbb", "ccc", repo = r)
previous
cfg <- git_config(repo = r)
subset(cfg, level == "local")
cfg$value[cfg$name == "aaa.bbb"]
previous <- git_config_set("aaa.bbb", NULL, repo = r)
previous
cfg <- git_config(repo = r)
subset(cfg, level == "local")
cfg$value[cfg$name == "aaa.bbb"]
unlink(r, recursive = TRUE)
\dontrun{
# Set global Git options
git_config_global_set("user.name", "Your Name")
git_config_global_set("user.email", "your@email.com")
git_config_global()
}
}
\seealso{
Other git:
\code{\link{git_archive}},
\code{\link{git_branch}()},
\code{\link{git_commit}()},
\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}