Title: | Simple Git Client for R |
---|---|
Description: | Simple git client for R based on 'libgit2' <https://libgit2.org> with support for SSH and HTTPS remotes. All functions in 'gert' use basic R data types (such as vectors and data-frames) for their arguments and return values. User credentials are shared with command line 'git' through the git-credential store and ssh keys stored on disk or ssh-agent. |
Authors: | Jeroen Ooms [aut, cre] , Jennifer Bryan [ctb] |
Maintainer: | Jeroen Ooms <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.1.4.9000 |
Built: | 2024-12-02 06:29:32 UTC |
Source: | https://github.com/r-lib/gert |
Exports the files in your repository to a zip file that is returned by the function.
git_archive_zip(file = NULL, repo = ".")
git_archive_zip(file = NULL, repo = ".")
file |
name of the output zip file. Default is returned by the function |
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
path to the zip file that was created
Other git:
git_branch()
,
git_commit()
,
git_config()
,
git_diff()
,
git_fetch()
,
git_ignore
,
git_merge()
,
git_rebase()
,
git_remote
,
git_repo
,
git_reset()
,
git_signature()
,
git_stash
,
git_tag
Create, list, and checkout branches.
git_branch(repo = ".") git_branch_list(local = NULL, repo = ".") git_branch_checkout(branch, force = FALSE, orphan = FALSE, repo = ".") git_branch_create( branch, ref = "HEAD", checkout = TRUE, force = FALSE, repo = "." ) git_branch_delete(branch, repo = ".") git_branch_move(branch, new_branch, force = FALSE, repo = ".") git_branch_fast_forward(ref, repo = ".") git_branch_set_upstream(upstream, branch = git_branch(repo), repo = ".") git_branch_exists(branch, local = TRUE, repo = ".")
git_branch(repo = ".") git_branch_list(local = NULL, repo = ".") git_branch_checkout(branch, force = FALSE, orphan = FALSE, repo = ".") git_branch_create( branch, ref = "HEAD", checkout = TRUE, force = FALSE, repo = "." ) git_branch_delete(branch, repo = ".") git_branch_move(branch, new_branch, force = FALSE, repo = ".") git_branch_fast_forward(ref, repo = ".") git_branch_set_upstream(upstream, branch = git_branch(repo), repo = ".") git_branch_exists(branch, local = TRUE, repo = ".")
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
local |
set TRUE to only check for local branches, FALSE to check for remote branches. Use NULL to return all branches. |
branch |
name of branch to check out |
force |
overwrite existing branch |
orphan |
if branch does not exist, checkout unborn branch |
ref |
string with a branch/tag/commit |
checkout |
move HEAD to the newly created branch |
new_branch |
target name of the branch once the move is performed; this name is validated for consistency. |
upstream |
remote branch from git_branch_list, for example |
Other git:
git_archive
,
git_commit()
,
git_config()
,
git_diff()
,
git_fetch()
,
git_ignore
,
git_merge()
,
git_rebase()
,
git_remote
,
git_repo
,
git_reset()
,
git_signature()
,
git_stash
,
git_tag
Fetch and checkout pull requests.
git_checkout_pull_request(pr = 1, remote = NULL, repo = ".") git_fetch_pull_requests(pr = "*", remote = NULL, repo = ".")
git_checkout_pull_request(pr = 1, remote = NULL, repo = ".") git_fetch_pull_requests(pr = "*", remote = NULL, repo = ".")
pr |
number with PR to fetch or check out. Use |
remote |
Optional. Name of a remote listed in |
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
By default git_fetch_pull_requests
will download all PR branches. To
remove these again simply use git_fetch(prune = TRUE)
.
To commit changes, start by staging the files to be included in the commit
using git_add()
or git_rm()
. Use git_status()
to see an overview of
staged and unstaged changes, and finally git_commit()
creates a new commit
with currently staged files.
git_commit_all()
is a convenience function that automatically stages and
commits all modified files. Note that git_commit_all()
does not add
new, untracked files to the repository. You need to make an explicit call to
git_add()
to start tracking new files.
git_log()
shows the most recent commits and git_ls()
lists all the files
that are being tracked in the repository. git_stat_files()
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 = ".")
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 = ".")
message |
a commit message |
author |
A git_signature value, default is |
committer |
A git_signature value, default is same as |
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
ref |
revision string with a branch/tag/commit value |
ancestor |
a reference to a potential ancestor commit |
files |
vector of paths relative to the git root directory.
Use |
force |
add files even if in gitignore |
staged |
return only staged (TRUE) or unstaged files (FALSE).
Use |
pathspec |
character vector with paths to match |
max |
lookup at most latest n parent commits |
after |
date or timestamp: only include commits starting this date |
git_status()
, git_ls()
: A data frame with one row per file
git_log()
: A data frame with one row per commit
git_commit()
, git_commit_all()
: A SHA
Other git:
git_archive
,
git_branch()
,
git_config()
,
git_diff()
,
git_fetch()
,
git_ignore
,
git_merge()
,
git_rebase()
,
git_remote
,
git_repo
,
git_reset()
,
git_signature()
,
git_stash
,
git_tag
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", "[email protected]") } 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)
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", "[email protected]") } 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)
Get or set Git options, as git config
does on the command line. Global
settings affect all of a user's Git operations (git config --global
),
whereas local settings are scoped to a specific repository (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.
local | global | |
get | git_config() |
git_config_global() |
set | git_config_set() |
git_config_global_set() |
git_config(repo = ".") git_config_global() git_config_set(name, value, repo = ".") git_config_global_set(name, value)
git_config(repo = ".") git_config_global() git_config_set(name, value, repo = ".") git_config_global_set(name, value)
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
name |
Name of the option to set |
value |
Value to set. Must be a string, logical, number or |
git_config()
: a data.frame
of the Git options "in force" in the context
of repo
, one row per option. The level
column reveals whether the
option is determined from global or local config.
git_config_global()
: a data.frame
, as for git_config()
, except only
for global Git options.
git_config_set()
, git_config_global_set()
: The previous value of
name
in local or global config, respectively. If this option was
previously unset, returns NULL
. Returns invisibly.
All entries in the name
column are automatically normalised to
lowercase (see
https://libgit2.org/libgit2/#HEAD/type/git_config_entry for details).
Other git:
git_archive
,
git_branch()
,
git_commit()
,
git_diff()
,
git_fetch()
,
git_ignore
,
git_merge()
,
git_rebase()
,
git_remote
,
git_repo
,
git_reset()
,
git_signature()
,
git_stash
,
git_tag
# 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) ## Not run: # Set global Git options git_config_global_set("user.name", "Your Name") git_config_global_set("user.email", "[email protected]") git_config_global() ## End(Not run)
# 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) ## Not run: # Set global Git options git_config_global_set("user.name", "Your Name") git_config_global_set("user.email", "[email protected]") git_config_global() ## End(Not run)
View changes in a commit or in the current working directory.
git_diff(ref = NULL, repo = ".") git_diff_patch(ref = NULL, repo = ".")
git_diff(ref = NULL, repo = ".") git_diff_patch(ref = NULL, repo = ".")
ref |
a reference such as |
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
Other git:
git_archive
,
git_branch()
,
git_commit()
,
git_config()
,
git_fetch()
,
git_ignore
,
git_merge()
,
git_rebase()
,
git_remote
,
git_repo
,
git_reset()
,
git_signature()
,
git_stash
,
git_tag
Functions to connect with a git server (remote) to fetch or push changes. The 'credentials' package is used to handle authentication, the credentials vignette explains the various authentication methods for SSH and HTTPS remotes.
git_fetch( remote = NULL, refspec = NULL, password = askpass, ssh_key = NULL, prune = FALSE, verbose = interactive(), repo = "." ) git_remote_ls( remote = NULL, password = askpass, ssh_key = NULL, verbose = interactive(), repo = "." ) git_push( remote = NULL, refspec = NULL, set_upstream = NULL, password = askpass, ssh_key = NULL, mirror = FALSE, force = FALSE, verbose = interactive(), repo = "." ) git_clone( url, path = NULL, branch = NULL, password = askpass, ssh_key = NULL, bare = FALSE, mirror = FALSE, verbose = interactive() ) git_pull(remote = NULL, rebase = FALSE, ..., repo = ".")
git_fetch( remote = NULL, refspec = NULL, password = askpass, ssh_key = NULL, prune = FALSE, verbose = interactive(), repo = "." ) git_remote_ls( remote = NULL, password = askpass, ssh_key = NULL, verbose = interactive(), repo = "." ) git_push( remote = NULL, refspec = NULL, set_upstream = NULL, password = askpass, ssh_key = NULL, mirror = FALSE, force = FALSE, verbose = interactive(), repo = "." ) git_clone( url, path = NULL, branch = NULL, password = askpass, ssh_key = NULL, bare = FALSE, mirror = FALSE, verbose = interactive() ) git_pull(remote = NULL, rebase = FALSE, ..., repo = ".")
remote |
Optional. Name of a remote listed in |
refspec |
string with mapping between remote and local refs. Default uses the default refspec from the remote, which usually fetches all branches. |
password |
a string or a callback function to get passwords for authentication
or password protected ssh keys. Defaults to askpass which
checks |
ssh_key |
path or object containing your ssh private key. By default we
look for keys in |
prune |
delete tracking branches that no longer exist on the remote, or are not in the refspec (such as pull requests). |
verbose |
display some progress info while downloading |
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
set_upstream |
change the branch default upstream to |
mirror |
use the |
force |
use the |
url |
remote url. Typically starts with |
path |
Directory of the Git repository to create. |
branch |
name of branch to check out locally |
bare |
use the |
rebase |
if TRUE we try to rebase instead of merge local changes. This is not possible in case of conflicts (you will get an error). |
... |
arguments passed to git_fetch |
Use git_fetch()
and git_push()
to sync a local branch with a remote
branch. Here git_pull()
is a wrapper for git_fetch()
which then tries to
fast-forward the local branch after fetching.
Other git:
git_archive
,
git_branch()
,
git_commit()
,
git_config()
,
git_diff()
,
git_ignore
,
git_merge()
,
git_rebase()
,
git_remote
,
git_repo
,
git_reset()
,
git_signature()
,
git_stash
,
git_tag
{# Clone a small repository git_dir <- file.path(tempdir(), 'antiword') git_clone('https://github.com/ropensci/antiword', git_dir) # Change into the repo directory olddir <- getwd() setwd(git_dir) # Show some stuff git_log() git_branch_list() git_remote_list() # Add a file write.csv(iris, 'iris.csv') git_add('iris.csv') # Commit the change jerry <- git_signature("Jerry", "[email protected]") git_commit('added the iris file', author = jerry) # Now in the log: git_log() # Cleanup setwd(olddir) unlink(git_dir, recursive = TRUE) }
{# Clone a small repository git_dir <- file.path(tempdir(), 'antiword') git_clone('https://github.com/ropensci/antiword', git_dir) # Change into the repo directory olddir <- getwd() setwd(git_dir) # Show some stuff git_log() git_branch_list() git_remote_list() # Add a file write.csv(iris, 'iris.csv') git_add('iris.csv') # Commit the change jerry <- git_signature("Jerry", "[email protected]") git_commit('added the iris file', author = jerry) # Now in the log: git_log() # Cleanup setwd(olddir) unlink(git_dir, recursive = TRUE) }
Test if files would be ignored by .gitignore
rules
git_ignore_path_is_ignored(path, repo = ".")
git_ignore_path_is_ignored(path, repo = ".")
path |
A character vector of paths to test within the repo |
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
A logical vector the same length as path
, indicating if the
paths would be ignored.
Other git:
git_archive
,
git_branch()
,
git_commit()
,
git_config()
,
git_diff()
,
git_fetch()
,
git_merge()
,
git_rebase()
,
git_remote
,
git_repo
,
git_reset()
,
git_signature()
,
git_stash
,
git_tag
Use git_merge
to merge a branch into the current head. Based on how the branches
have diverged, the function will select a fast-forward or merge-commit strategy.
git_merge(ref, commit = TRUE, squash = FALSE, repo = ".") git_merge_stage_only(ref, squash = FALSE, repo = ".") git_merge_find_base(ref, target = "HEAD", repo = ".") git_merge_analysis(ref, repo = ".") git_merge_abort(repo = ".")
git_merge(ref, commit = TRUE, squash = FALSE, repo = ".") git_merge_stage_only(ref, squash = FALSE, repo = ".") git_merge_find_base(ref, target = "HEAD", repo = ".") git_merge_analysis(ref, repo = ".") git_merge_abort(repo = ".")
ref |
branch or commit that you want to merge |
commit |
automatically create a merge commit if the merge succeeds without
conflicts. Set this to |
squash |
omits the second parent from the commit, which make the merge a regular single-parent commit. |
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
target |
the branch where you want to merge into. Defaults to current |
By default git_merge
automatically commits the merge commit upon success.
However if the merge fails with merge-conflicts, or if commit
is set to
FALSE
, the changes are staged and the repository is put in merging state,
and you have to manually run git_commit
or git_merge_abort
to proceed.
Other functions are more low-level tools that are used by git_merge
.
git_merge_find_base
looks up the commit where two branches have diverged
(i.e. the youngest common ancestor). The git_merge_analysis
is used to
test if a merge can simply be fast forwarded or not.
The git_merge_stage_only
function applies and stages changes, without
committing or fast-forwarding.
Other git:
git_archive
,
git_branch()
,
git_commit()
,
git_config()
,
git_diff()
,
git_fetch()
,
git_ignore
,
git_rebase()
,
git_remote
,
git_repo
,
git_reset()
,
git_signature()
,
git_stash
,
git_tag
Returns a pointer to a libgit2 repository object.This function is mainly for internal use; users should simply reference a repository in gert by by the path to the directory.
git_open(repo = ".")
git_open(repo = ".")
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
an pointer to the libgit2 repository
r <- tempfile(pattern = "gert") git_init(r) r_ptr <- git_open(r) r_ptr git_open(r_ptr) git_info(r) # cleanup unlink(r, recursive = TRUE)
r <- tempfile(pattern = "gert") git_init(r) r_ptr <- git_open(r) r_ptr git_open(r_ptr) git_info(r) # cleanup unlink(r, recursive = TRUE)
A cherry-pick applies the changes from a given commit (from another branch) onto the current branch. A rebase resets the branch to the state of another branch (upstream) and then re-applies your local changes by cherry-picking each of your local commits onto the upstream commit history.
git_rebase_list(upstream = NULL, repo = ".") git_rebase_commit(upstream = NULL, repo = ".") git_cherry_pick(commit, repo = ".") git_ahead_behind(upstream = NULL, ref = "HEAD", repo = ".")
git_rebase_list(upstream = NULL, repo = ".") git_rebase_commit(upstream = NULL, repo = ".") git_cherry_pick(commit, repo = ".") git_ahead_behind(upstream = NULL, ref = "HEAD", repo = ".")
upstream |
branch to which you want to rewind and re-apply your local commits. The default uses the remote upstream branch with the current state on the git server, simulating git_pull. |
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
commit |
id of the commit to cherry pick |
ref |
string with a branch/tag/commit |
git_rebase_list
shows your local commits that are missing from the upstream
history, and if they conflict with upstream changes. It does so by performing
a rebase dry-run, without committing anything. If there are no conflicts, you
can use git_rebase_commit
to rewind and rebase your branch onto upstream
.
Gert only support a clean rebase; it never leaves the repository in unfinished
"rebasing" state. If conflicts arise, git_rebase_commit
will raise an error
without making changes.
Other git:
git_archive
,
git_branch()
,
git_commit()
,
git_config()
,
git_diff()
,
git_fetch()
,
git_ignore
,
git_merge()
,
git_remote
,
git_repo
,
git_reset()
,
git_signature()
,
git_stash
,
git_tag
List, add, configure, or remove remotes.
git_remote_list(repo = ".") git_remote_add(url, name = "origin", refspec = NULL, repo = ".") git_remote_remove(remote, repo = ".") git_remote_info(remote = NULL, repo = ".") git_remote_set_url(url, remote = NULL, repo = ".") git_remote_set_pushurl(url, remote = NULL, repo = ".") git_remote_refspecs(remote = NULL, repo = ".")
git_remote_list(repo = ".") git_remote_add(url, name = "origin", refspec = NULL, repo = ".") git_remote_remove(remote, repo = ".") git_remote_info(remote = NULL, repo = ".") git_remote_set_url(url, remote = NULL, repo = ".") git_remote_set_pushurl(url, remote = NULL, repo = ".") git_remote_refspecs(remote = NULL, repo = ".")
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
url |
server url (https or ssh) |
name |
unique name for the new remote |
refspec |
optional string with the remote fetch value |
remote |
name of an existing remote. Default |
Other git:
git_archive
,
git_branch()
,
git_commit()
,
git_config()
,
git_diff()
,
git_fetch()
,
git_ignore
,
git_merge()
,
git_rebase()
,
git_repo
,
git_reset()
,
git_signature()
,
git_stash
,
git_tag
Use git_init()
to create a new repository or git_find()
to discover an
existing local repository. git_info()
shows basic information about a
repository, such as the SHA and branch of the current HEAD.
git_init(path = ".", bare = FALSE) git_find(path = ".") git_info(repo = ".")
git_init(path = ".", bare = FALSE) git_find(path = ".") git_info(repo = ".")
path |
the location of the git repository, see details. |
bare |
if true, a Git repository without a working directory is created |
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
For git_init()
the path
parameter sets the directory of the git repository
to create. If this directory already exists, it must be empty. If it does
not exist, it is created, along with any intermediate directories that don't
yet exist. For git_find()
the path
arguments specifies the directory at
which to start the search for a git repository. If it is not a git repository
itself, then its parent directory is consulted, then the parent's parent, and
so on.
The path to the Git repository.
Other git:
git_archive
,
git_branch()
,
git_commit()
,
git_config()
,
git_diff()
,
git_fetch()
,
git_ignore
,
git_merge()
,
git_rebase()
,
git_remote
,
git_reset()
,
git_signature()
,
git_stash
,
git_tag
# directory does not yet exist r <- tempfile(pattern = "gert") git_init(r) git_find(r) # create a child directory, then a grandchild, then search r_grandchild_dir <- file.path(r, "aaa", "bbb") dir.create(r_grandchild_dir, recursive = TRUE) git_find(r_grandchild_dir) # cleanup unlink(r, recursive = TRUE) # directory exists but is empty r <- tempfile(pattern = "gert") dir.create(r) git_init(r) git_find(r) # cleanup unlink(r, recursive = TRUE)
# directory does not yet exist r <- tempfile(pattern = "gert") git_init(r) git_find(r) # create a child directory, then a grandchild, then search r_grandchild_dir <- file.path(r, "aaa", "bbb") dir.create(r_grandchild_dir, recursive = TRUE) git_find(r_grandchild_dir) # cleanup unlink(r, recursive = TRUE) # directory exists but is empty r <- tempfile(pattern = "gert") dir.create(r) git_init(r) git_find(r) # cleanup unlink(r, recursive = TRUE)
git_reset_hard()
resets the index and working tree
git_reset_soft()
does not touch the index file or the working tree
git_reset_mixed()
resets the index but not the working tree.
git_reset_hard(ref = "HEAD", repo = ".") git_reset_soft(ref = "HEAD", repo = ".") git_reset_mixed(ref = "HEAD", repo = ".")
git_reset_hard(ref = "HEAD", repo = ".") git_reset_soft(ref = "HEAD", repo = ".") git_reset_mixed(ref = "HEAD", repo = ".")
ref |
string with a branch/tag/commit |
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
Other git:
git_archive
,
git_branch()
,
git_commit()
,
git_config()
,
git_diff()
,
git_fetch()
,
git_ignore
,
git_merge()
,
git_rebase()
,
git_remote
,
git_repo
,
git_signature()
,
git_stash
,
git_tag
A signature contains the author and timestamp of a commit. Each commit includes a signature of the author and committer (which can be identical).
git_signature_default(repo = ".") git_signature(name, email, time = NULL) git_signature_parse(sig)
git_signature_default(repo = ".") git_signature(name, email, time = NULL) git_signature_parse(sig)
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
name |
Real name of the committer |
email |
Email address of the committer |
time |
timestamp of class POSIXt or NULL |
sig |
string in proper |
A signature string has format "Real Name <email> timestamp tzoffset"
. The
timestamp tzoffset
piece can be omitted in which case the current local
time is used. If not omitted, timestamp
must contain the number
of seconds since the Unix epoch and tzoffset
is the timezone offset in
hhmm
format (note the lack of a colon separator)
Other git:
git_archive
,
git_branch()
,
git_commit()
,
git_config()
,
git_diff()
,
git_fetch()
,
git_ignore
,
git_merge()
,
git_rebase()
,
git_remote
,
git_repo
,
git_reset()
,
git_stash
,
git_tag
# Your default user try(git_signature_default()) # Specify explicit name and email git_signature("Some committer", "[email protected]") # Create signature for an hour ago (sig <- git_signature("Han", "[email protected]", Sys.time() - 3600)) # Parse a signature git_signature_parse(sig) git_signature_parse("Emma <[email protected]>")
# Your default user try(git_signature_default()) # Specify explicit name and email git_signature("Some committer", "[email protected]") # Create signature for an hour ago (sig <- git_signature("Han", "[email protected]", Sys.time() - 3600)) # Parse a signature git_signature_parse(sig) git_signature_parse("Emma <[email protected]>")
Temporary stash away changed from the working directory.
git_stash_save( message = "", keep_index = FALSE, include_untracked = FALSE, include_ignored = FALSE, repo = "." ) git_stash_pop(index = 0, repo = ".") git_stash_drop(index = 0, repo = ".") git_stash_list(repo = ".")
git_stash_save( message = "", keep_index = FALSE, include_untracked = FALSE, include_ignored = FALSE, repo = "." ) git_stash_pop(index = 0, repo = ".") git_stash_drop(index = 0, repo = ".") git_stash_list(repo = ".")
message |
optional message to store the stash |
keep_index |
changes already added to the index are left intact in the working directory |
include_untracked |
untracked files are also stashed and then cleaned up from the working directory |
include_ignored |
ignored files are also stashed and then cleaned up from the working directory |
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
index |
The position within the stash list. 0 points to the most recent stashed state. |
Other git:
git_archive
,
git_branch()
,
git_commit()
,
git_config()
,
git_diff()
,
git_fetch()
,
git_ignore
,
git_merge()
,
git_rebase()
,
git_remote
,
git_repo
,
git_reset()
,
git_signature()
,
git_tag
Interact with submodules in the repository.
git_submodule_list(repo = ".") git_submodule_info(submodule, repo = ".") git_submodule_init(submodule, overwrite = FALSE, repo = ".") git_submodule_set_to(submodule, ref, checkout = TRUE, repo = ".") git_submodule_add(url, path = basename(url), ref = "HEAD", ..., repo = ".") git_submodule_fetch(submodule, ..., repo = ".")
git_submodule_list(repo = ".") git_submodule_info(submodule, repo = ".") git_submodule_init(submodule, overwrite = FALSE, repo = ".") git_submodule_set_to(submodule, ref, checkout = TRUE, repo = ".") git_submodule_add(url, path = basename(url), ref = "HEAD", ..., repo = ".") git_submodule_fetch(submodule, ..., repo = ".")
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
submodule |
name of the submodule |
overwrite |
overwrite existing entries |
ref |
a branch or tag or hash with |
checkout |
actually switch the contents of the directory to this commit |
url |
full git url of the submodule |
path |
relative of the submodule |
... |
extra arguments for git_fetch for authentication things |
Create and list tags.
git_tag_list(match = "*", repo = ".") git_tag_create(name, message, ref = "HEAD", repo = ".") git_tag_delete(name, repo = ".") git_tag_push(name, ..., repo = ".")
git_tag_list(match = "*", repo = ".") git_tag_create(name, message, ref = "HEAD", repo = ".") git_tag_delete(name, repo = ".") git_tag_push(name, ..., repo = ".")
match |
pattern to filter tags (use |
repo |
The path to the git repository. If the directory is not a
repository, parent directories are considered (see git_find). To disable
this search, provide the filepath protected with |
name |
tag name |
message |
tag message |
ref |
target reference to tag |
... |
other arguments passed to git_push |
Other git:
git_archive
,
git_branch()
,
git_commit()
,
git_config()
,
git_diff()
,
git_fetch()
,
git_ignore
,
git_merge()
,
git_rebase()
,
git_remote
,
git_repo
,
git_reset()
,
git_signature()
,
git_stash
libgit2_config()
reveals which version of libgit2 gert is using and which
features are supported, such whether you are able to use ssh remotes.
libgit2_config()
libgit2_config()
libgit2_config()
libgit2_config()
This function exists mostly to guard examples that rely on having a user
configured, in order to make commits. user_is_configured()
makes no
distinction between local or global user config.
user_is_configured(repo = ".")
user_is_configured(repo = ".")
repo |
An optional |
TRUE
if user.name
and user.email
are set locally or globally,
FALSE
otherwise.
user_is_configured()
user_is_configured()