git2r (version 0.10.1)

add: Add file(s) to index

Description

Add file(s) to index

Usage

add(repo, path)

## S3 method for class 'git_repository,character': add(repo, path)

Arguments

repo
The repository object.
path
character vector with filenames to add. The path must be relative to the repository's working folder. Only non-ignored files are added. If path is a directory, files in sub-folders are added (if non-ignored)

Value

  • invisible(NULL)

Examples

Run this code
## Initialize a repository
path <- tempfile(pattern="git2r-")
dir.create(path)
repo <- init(path)

## Create a user
config(repo, user.name="Alice", user.email="alice@example.org")

## Create a file
writeLines("Hello world!", file.path(path, "file-to-add.txt"))

## Add file to repository
add(repo, "file-to-add.txt")

## View status of repository
status(repo)

Run the code above in your browser using DataLab