git_init: Create a new Git repository

Description Usage Arguments Details Value Examples

Description

Create a new Git repository or re-initialize an existing one, similar to git init.

Usage

1
git_init(path = ".")

Arguments

path

Where to create the new Git repo. Defaults to current working directory. If the path doesn't exist, it will be created via dir.create(path, recursive = TRUE).

Details

Will bad things happen if you git_init() in a directory that is already a Git repo? No, it's fine! To quote the git-init man page, "running git init in an existing repository is safe. It will not overwrite things that are already there". A legitimate reason to do this is to pick up a new Git template, a topic which newcomers can safely ignore.

git_init() will not create a Git repo in a subdirectory of an existing Git repo. The proper way to do this is via Git submodules, which is beyond the current scope of the package.

Value

Path to the associated Git repo.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
repo <- git_init(tempfile("git-init-example-"))

## switch working directory to the repo
owd <- setwd(repo)

## Config local user and make a commit
git_config(user.name = "thelma", user.email = "thelma@example.org")
write("I don't ever remember feeling this awake.", "thelma.txt")
git_commit("thelma.txt", message = "thelma is awake")

git_history()

setwd(owd)

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