pull-methods: Pull

Description Usage Arguments Value Examples

Description

Pull

Usage

1
2
3
4
5
pull(repo, credentials = NULL, merger = default_signature(repo))

## S4 method for signature 'git_repository'
pull(repo, credentials = NULL,
  merger = default_signature(repo))

Arguments

repo

the repository

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).

merger

Who made the merge, if the merge is non-fast forward merge that creates a merge commit.

Value

invisible(NULL)

Examples

 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
## Not run: 
## Initialize repositories
path_bare <- tempfile(pattern="git2r-")
path_repo_1 <- tempfile(pattern="git2r-")
path_repo_2 <- tempfile(pattern="git2r-")
dir.create(path_bare)
dir.create(path_repo_1)
dir.create(path_repo_2)
repo_bare <- init(path_bare, bare = TRUE)
repo_1 <- clone(path_bare, path_repo_1)

## Config first user and commit a file
config(repo_1, user.name="Alice", user.email="[email protected]")

## 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")

## Push commits from first repository to bare repository
## Adds an upstream tracking branch to branch 'master'
push(repo_1, "origin", "refs/heads/master")

## Clone to second repository
repo_2 <- clone(path_bare, path_repo_2)
config(repo_2, user.name="Bob", user.email="[email protected]")

## Change file and commit
writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do",
             "eiusmod tempor incididunt ut labore et dolore magna aliqua."),
           file.path(path_repo_1, "example.txt"))
add(repo_1, "example.txt")
commit(repo_1, "Second commit message")

## Push commits from first repository to bare repository
push(repo_1)

## Pull changes to repo_2
pull(repo_2)

## Change file again and commit. This time in repository 2
writeLines(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"),
           file.path(path_repo_2, "example.txt"))
add(repo_2, "example.txt")
commit(repo_2, "Third commit message")

## Push commits from second repository to bare repository
push(repo_2)

## Pull changes to repo_1
pull(repo_1)

## List commits in repositories
commits(repo_1)
commits(repo_2)
commits(repo_bare)

## End(Not run)

Example output

cloning into '/work/tmp/tmp/RtmpIJNdlD/git2r-9d178ef0c28'...
[4729180] 2017-09-06: First commit message
cloning into '/work/tmp/tmp/RtmpIJNdlD/git2r-9d1318c7759'...
[673d904] 2017-09-06: Second commit message
[updated] 4729180fb6..673d904fe5 refs/remotes/origin/master
Merge: Fast-forward
[8de3674] 2017-09-06: Third commit message
[updated] 673d904fe5..8de367456b refs/remotes/origin/master
Merge: Fast-forward
[[1]]
[8de3674] 2017-09-06: Third commit message

[[2]]
[673d904] 2017-09-06: Second commit message

[[3]]
[4729180] 2017-09-06: First commit message

[[1]]
[8de3674] 2017-09-06: Third commit message

[[2]]
[673d904] 2017-09-06: Second commit message

[[3]]
[4729180] 2017-09-06: First commit message

[[1]]
[8de3674] 2017-09-06: Third commit message

[[2]]
[673d904] 2017-09-06: Second commit message

[[3]]
[4729180] 2017-09-06: First commit message

git2r documentation built on July 20, 2017, 1:03 a.m.

Related to pull-methods in git2r...