git2r (version 0.10.1)

blame: Get blame for file

Description

Get blame for file

Usage

blame(repo, path)

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

Arguments

repo
The repository
path
Path to the file to consider

Value

  • S4 class git_blame object

Examples

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

## Create a first user and commit a file
config(repo, user.name="Alice", user.email="alice@example.org")
writeLines("Hello world!", file.path(path, "example.txt"))
add(repo, "example.txt")
commit(repo, "First commit message")

## Create a second user and change the file
config(repo, user.name="Bob", user.email="bob@example.org")
writeLines(c("Hello world!", "HELLO WORLD!", "HOLA"),
           file.path(path, "example.txt"))
add(repo, "example.txt")
commit(repo, "Second commit message")

## Check blame
blame(repo, "example.txt")

Run the code above in your browser using DataCamp Workspace