oldwd <- getwd()
repo <- file.path(tempdir(), "myrepo")
git_init(repo)
setwd(repo)
# Set a user if no default
if(!user_is_configured()){
git_config_set("user.name", "Jerry")
git_config_set("user.email", "jerry@gmail.com")
}
writeLines(letters[1:6], "alphabet.txt")
git_status()
git_add("alphabet.txt")
git_status()
git_commit("Start alphabet file")
git_status()
git_ls()
git_log()
cat(letters[7:9], file = "alphabet.txt", sep = "\n", append = TRUE)
git_status()
git_commit_all("Add more letters")
# cleanup
setwd(oldwd)
unlink(repo, recursive = TRUE)
Run the code above in your browser using DataLab