Skip to content
Stefan Widgren edited this page Jun 24, 2014 · 3 revisions

The central object in the git2r package is the S4 class git_repository. The following three methods can instantiate a repository; init, repository and clone.

Class "git_repository"

S4 class to handle a git repository

Slots

path: Path to a git repository

Create a new repository

Create a new repository in a temporary directory using init

## Create a temporary directory to hold the repository
path <- tempfile(pattern="git2r-")
dir.create(path)

## Initialize the repository
repo <- init(path)

Display a brief summary of the new repository

repo
#> Local:    /tmp/Rtmp7CXPlx/git2r-1ae2305c0e8d/
#> Head:     nothing commited (yet)

Check if repository is bare

is_bare(repo)
#> [1] FALSE

Check if repository is empty

is_empty(repo)
#> [1] TRUE
Clone this wiki locally