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_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_descendant_of(ancestor, ref = "HEAD", repo = ".") git_add(files, force = FALSE, repo = ".") git_rm(files, repo = ".") git_status(staged = NULL, repo = ".") git_conflicts(repo = ".") git_ls(repo = ".") git_log(ref = "HEAD", max = 100, 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 |
| max | lookup at most latest n parent commits |
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_merge(),
git_rebase(),
git_remote,
git_repo,
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", "jerry@gmail.com") } writeLines(letters[1:6], "alphabet.txt") git_status()#> # A tibble: 1 x 3 #> file status staged #> <chr> <chr> <lgl> #> 1 alphabet.txt new FALSEgit_add("alphabet.txt")#> # A tibble: 1 x 3 #> file status staged #> <chr> <chr> <lgl> #> 1 alphabet.txt new TRUEgit_status()#> # A tibble: 1 x 3 #> file status staged #> <chr> <chr> <lgl> #> 1 alphabet.txt new TRUEgit_commit("Start alphabet file")#> [1] "d9b05b62c6465df039ef34c8582c2612c15093f3"git_status()#> # A tibble: 0 x 3 #> # … with 3 variables: file <chr>, status <chr>, staged <lgl>git_ls()#> # A tibble: 1 x 4 #> path filesize modified created #> * <chr> <dbl> <dttm> <dttm> #> 1 alphabet.txt 12 2021-04-20 14:06:20 2021-04-20 14:06:20git_log()#> # A tibble: 1 x 6 #> commit author time files merge message #> * <chr> <chr> <dttm> <int> <lgl> <chr> #> 1 d9b05b62c6465df0… andersone1 <an… 2021-04-20 14:06:20 1 FALSE "Start alph…#> # A tibble: 1 x 3 #> file status staged #> <chr> <chr> <lgl> #> 1 alphabet.txt modified FALSEgit_commit_all("Add more letters")#> [1] "b758c9c13e68246457f95b4e6172ff9949808770"