wflow_git_commit adds and commits files with Git. This is a convenience function to run Git commands from the R console instead of the shell. For most use cases, you should use wflow_publish instead, which calls wflow_git_commit and then subsequently also builds and commits the website files.

wflow_git_commit(
  files = NULL,
  message = NULL,
  all = FALSE,
  force = FALSE,
  dry_run = FALSE,
  project = "."
)

Arguments

files

character (default: NULL). Files to be added and committed with Git. Supports file globbing.

message

character (default: NULL). A commit message.

all

logical (default: FALSE). Automatically stage files that have been modified and deleted. Equivalent to: git commit -a

force

logical (default: FALSE). Allow adding otherwise ignored files. Equivalent to: git add -f

dry_run

logical (default: FALSE). Preview the proposed action but do not actually add or commit any files.

project

character (default: ".") By default the function assumes the current working directory is within the project. If this is not true, you'll need to provide the path to the project directory.

Value

An object of class wflow_git_commit, which is a list with the following elements:

  • files: The input argument files.

  • message: The message describing the commit.

  • all: The input argument all.

  • force: The input argument force.

  • dry_run: The input argument dry_run.

  • commit: The object returned by git2r::commit (only included if dry_run == FALSE).

  • commit_files: The relative path(s) to the file(s) included in the commit (only included if dry_run == FALSE).

Details

Some potential use cases for wflow_git_commit:

  • Commit drafts which you do not yet want to be included in the website

  • Commit files which do not directly affect the website (e.g. when you are writing scripts for a data processing pipeline)

  • Manually commit files in docs/ (proceed with caution!). This should only be done for content that is not automatically generated from the source files in the analysis directory, e.g. an image file you want to include in one of your pages.

Under the hood, wflow_git_commit is a wrapper for add and commit from the package git2r.

See also

Examples

if (FALSE) {

# Commit a single file
wflow_git_commit("analysis/file.Rmd", "Add new analysis")
# Commit multiple files
wflow_git_commit(c("code/process-data.sh", "output/small-data.txt"),
             "Process data set")
# Add and commit all tracked files, similar to `git commit -a`
wflow_git_commit(message = "Lots of changes", all = TRUE)
}