Description Usage Arguments Details Value Functions References Examples
git_config
and convenience wrappers git_config_global
and
git_config_local
can be used to get or set Git configuration. All
rely on git2r::config()
.
1 2 3 4 5 | git_config(..., where = c("de_facto", "local", "global"), repo = ".")
git_config_global(..., repo = ".")
git_config_local(..., repo = ".")
|
... |
The Git configuration variables to get or set. If unspecified,
all are returned, i.e. the output should match the result of |
where |
Specifies which variables. The default, |
repo |
Path to a Git repo. If unspecified, current working directory is checked to see if it is or is inside a Git repo. |
Variables can be listed by specifying the names as strings or in a unnamed
list or vector of strings. Don't specify anything if you want to see them
all. Non-existent variables will return value NULL
.
Variables can be set by specifying them as arguments in variable =
value
form or as a named list. To unset a variable, i.e. git config
--unset
, specify NULL
as the value.
When variables are set, the previous values are returned in an invisible
named list, analogous to par
or setwd
. Such a
list can be passed back in to git_config_local
or
git_config_global
to restore the previous configuration.
Consult the git-config man page for a long yet non-comprehensive list of variables.
For future GitHub happiness, it is highly recommended that you set
user.email
to an email address that is associated with your GitHub
account: https://help.github.com/articles/setting-your-email-in-git/.
A named list of Git configuration variables, with class
githug_list
for pretty-printing purposes.
git_config_global
: Get or set global Git config, a la git config
--global
git_config_local
: Get or set local Git config, a la git config
--local
Getting Started - First-Time Git Setup from the Pro Git book by Scott Chacon and Ben Straub
Customizing Git - Git Configuration from the Pro Git book by Scott Chacon and Ben Straub
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 | ## see git config currently in effect, based on working directory
git_config() # local > global, same as git_config(where = "de_facto")
git_config_local() # same as git_config(where = "local")
git_config_global() # same as git_config(where = "global")
## set and get global config
## Not run:
## set and list global config
git_config_global(user.name = "thelma", user.email = "thelma@example.org")
git_config_global("user.name", "user.email")
## End(Not run)
## specify a Git repo
repo <- git_init(tempfile("githug-config-example-"))
git_config_local(repo = repo)
## switch working directory to the repo
owd <- setwd(repo)
## set local variables for current repo
git_config_local(user.name = "louise", user.email = "louise@example.org")
## get specific local variables, including a non-existent one
git_config_local("user.name", "color.branch", "user.email")
## set local variables, then restore
ocfg <- git_config_local(user.name = "oops", user.email = "oops@example.org")
git_config_local("user.name", "user.email")
git_config_local(ocfg)
git_config_local("user.name", "user.email")
## set a custom variable
ocfg <- git_config_local(githug.lol = "wut")
git_config_local("githug.lol")
setwd(owd)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.