git_file_rename: Rename or move a file and stage both ends

Description Usage Arguments Details Value Examples

Description

Rename a file and stage both ends of the transaction, i.e. the deletion of the file under its original name and the addition of the file under its new name. You still need to make the commit. If Git recognizes a rename event, then the history of the file will be preserved. This is worth striving for. Maximize the chance of this happy event by making the rename/move a distinct operation that is not muddled up with other changes to the file.

Usage

1
2
3
git_file_rename(from, to, repo = ".")

git_mv(from, to, repo = ".")

Arguments

from

Path to an existing file, relative to the repo working directory

to

The desired new name, relative to the repo working directory

repo

Path to a Git repo. If unspecified, current working directory is checked to see if it is or is inside a Git repo.

Details

This is an extremely simple implementation of basic git mv. Why? True git mv is offered neither by libgit2 nor, therefore, by git2r.

Value

Nothing

Examples

1
2
3
4
5
6
7
8
repo <- git_init(tempfile("githug-"))
owd <- setwd(repo)
write("Are these girls real smart or real real lucky?", "louise.txt")
git_commit(all = TRUE, message = "filename is all wrong")
git_mv(from = "louise.txt", to = "max.txt")
git_commit(all = TRUE, message = "corrected filename")
git_history()
setwd(owd)

jennybc/githug documentation built on May 19, 2019, 5:05 a.m.