Learn R Programming

git2r (version 0.35.0)

in_repository: Determine if a directory is in a git repository

Description

The lookup start from path and walk across parent directories if nothing has been found.

Usage

in_repository(path = ".")

Value

TRUE if directory is in a git repository else FALSE

Arguments

path

The path to the directory.

Examples

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

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

## Check if path is in a git repository
in_repository(path)

## Check if working directory is in a git repository
setwd(path)
in_repository()
}

Run the code above in your browser using DataLab