Learn R Programming

workflowr (version 0.7.0)

wflow_commit: Commit files

Description

wflow_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_commit and then subsequently also builds and commits the website files.

Usage

wflow_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.

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_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 git_commit-class object returned by git2r (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_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_commit is a wrapper for add and commit from the package git2r.

See Also

wflow_publish

Examples

Run this code
# NOT RUN {
# Commit a single file
wflow_commit("analysis/file.Rmd", "Add new analysis")
# Commit multiple files
wflow_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_commit(message = "Lots of changes", all = TRUE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab