1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/repository.R
\name{clone}
\alias{clone}
\title{Clone a remote repository}
\usage{
clone(
url = NULL,
local_path = NULL,
bare = FALSE,
branch = NULL,
checkout = TRUE,
credentials = NULL,
progress = TRUE
)
}
\arguments{
\item{url}{The remote repository to clone}
\item{local_path}{Local directory to clone to.}
\item{bare}{Create a bare repository. Default is FALSE.}
\item{branch}{The name of the branch to checkout. Default is NULL
which means to use the remote's default branch.}
\item{checkout}{Checkout HEAD after the clone is complete. Default
is TRUE.}
\item{credentials}{The credentials for remote repository
access. Default is NULL. To use and query an ssh-agent for the
ssh key credentials, let this parameter be NULL (the default).}
\item{progress}{Show progress. Default is TRUE.}
}
\value{
A \code{git_repository} object.
}
\description{
Clone a remote repository
}
\examples{
\dontrun{
## Initialize repository
path_repo_1 <- tempfile(pattern="git2r-")
path_repo_2 <- tempfile(pattern="git2r-")
dir.create(path_repo_1)
dir.create(path_repo_2)
repo_1 <- init(path_repo_1)
## Config user and commit a file
config(repo_1, user.name = "Alice", user.email = "alice@example.org")
## Write to a file and commit
writeLines(
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do",
file.path(path_repo_1, "example.txt"))
add(repo_1, "example.txt")
commit(repo_1, "First commit message")
## Change file and commit
lines <- c(
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do",
"eiusmod tempor incididunt ut labore et dolore magna aliqua.")
writeLines(lines, file.path(path_repo_1, "example.txt"))
add(repo_1, "example.txt")
commit(repo_1, "Second commit message")
## Change file again and commit.
lines <- c(
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do",
"eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad",
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut")
writeLines(lines, file.path(path_repo_1, "example.txt"))
add(repo_1, "example.txt")
commit(repo_1, "Third commit message")
## Clone to second repository
repo_2 <- clone(path_repo_1, path_repo_2)
## List commits in repositories
commits(repo_1)
commits(repo_2)
}
}
\seealso{
\link{repository}, \code{\link{cred_user_pass}},
\code{\link{cred_ssh_key}}
}
|