• local_repo_clone - Clones a GitHub repository to a local directory.

  • local_repo_add - Equivalent to git add - stages a file in a local repository.

  • local_repo_commit - Equivalent to git commit - commits staged files in a local repository.

  • local_repo_push - Equivalent to git push - push a local repository.

  • local_repo_pull - Equivalent to git pull - pull a local repository.

  • local_repo_branch - Equivalent to git branch - create a branch in a local repository.

  • local_repo_log - Equivalent to git log - returns a data frame for git log entries.

local_repo_add(repo_dir, files = ".")

local_repo_branch(repo_dir, branch)

local_repo_clone(
  repo,
  local_path = ".",
  branch = NULL,
  mirror = FALSE,
  verbose = FALSE
)

local_repo_commit(repo_dir, message)

local_repo_log(repo_dir, max = 100)

local_repo_pull(repo_dir, verbose = FALSE)

local_repo_push(
  repo_dir,
  remote = "origin",
  branch = NULL,
  force = FALSE,
  prompt = TRUE,
  mirror = FALSE,
  verbose = FALSE
)

Arguments

repo_dir

Vector of repo directories or a single directory containing one or more repos.

files

Files to be staged

branch

Repository branch to use.

repo

GitHub repo address with the form owner/name.

local_path

Local directory to store cloned repos.

mirror

Equivalent to --mirror

verbose

Display verbose output.

message

Commit message

max

Maximum number of log entries to retrieve per repo.

remote

Repository remote to use.

force

Force push?

prompt

Prompt before force push?

Details

All of these functions depend on the gert library being installed.

Examples

# \dontrun{ repo = repo_create("ghclass-test", "local_repo_test")
#> Created repo 'ghclass-test/local_repo_test'.
dir = file.path(tempdir(), "repos") local_repo = local_repo_clone(repo, dir)
#> Cloned 'ghclass-test/local_repo_test'.
local_repo_log(dir)
#> # A tibble: 1 x 7 #> repo commit author time files merge message #> <fs::path> <chr> <chr> <dttm> <int> <lgl> <chr> #> 1 /private/var/fold… bf50f381b… Colin R… 2020-12-20 12:46:42 1 FALSE Initia…
# Make a local change and push writeLines("Hello World", file.path(local_repo, "hello.txt")) local_repo_add(local_repo, "hello.txt")
#> Added files 'hello.txt' to 'local_repo_test'.
local_repo_commit(local_repo, "Added hello world")
#> Committed changes to 'local_repo_test'.
local_repo_push(local_repo)
#> Pushed from local repo 'local_repo_test' to 'origin/main'.
repo_commits(repo)
#> # A tibble: 2 x 6 #> repo login name email date msg #> <chr> <chr> <chr> <chr> <dttm> <chr> #> 1 ghclass-test/loca… rundel Colin Ru… rundel@gm… 2020-12-20 12:46:45 Added hell… #> 2 ghclass-test/loca… rundel Colin Ru… rundel@gm… 2020-12-20 12:46:42 Initial co…
# Pulling remote changes repo_modify_file(repo, "hello.txt", pattern = ".*", content = "!!!", method = "after")
#> Modified file 'ghclass-test/local_repo_test/hello.txt'.
local_repo_pull(local_repo)
#> Performing fast-forward merge, no commit needed
#> Pulled to local repo 'local_repo_test'.
local_repo_log(dir)
#> # A tibble: 3 x 7 #> repo commit author time files merge message #> <fs::path> <chr> <chr> <dttm> <int> <lgl> <chr> #> 1 /private/var/fol… 852e5dd3b… Colin R… 2020-12-20 12:46:50 1 FALSE "Modifi… #> 2 /private/var/fol… cbc667bcd… Colin R… 2020-12-20 12:46:45 1 FALSE "Added … #> 3 /private/var/fol… bf50f381b… Colin R… 2020-12-20 12:46:42 1 FALSE "Initia…
repo_delete("ghclass-test/local_repo_test", prompt=FALSE)
#> Deleted repo 'ghclass-test/local_repo_test'.
# }