6 git-pull - Fetch from and merge with another repository or a local branch
11 'git-pull' <options> <repository> <refspec>...
16 Runs `git-fetch` with the given parameters, and calls `git-merge`
17 to merge the retrieved head(s) into the current branch.
19 Note that you can use `.` (current directory) as the
20 <repository> to pull from the local repository -- this is useful
21 when merging local branches into the current branch.
26 include::merge-options.txt[]
28 include::fetch-options.txt[]
30 include::pull-fetch-param.txt[]
32 include::urls-remotes.txt[]
34 include::merge-strategies.txt[]
39 Often people use `git pull` without giving any parameter.
40 Traditionally, this has been equivalent to saying `git pull
41 origin`. However, when configuration `branch.<name>.remote` is
42 present while on branch `<name>`, that value is used instead of
45 In order to determine what URL to use to fetch from, the value
46 of the configuration `remote.<origin>.url` is consulted
47 and if there is not any such variable, the value on `URL: ` line
48 in `$GIT_DIR/remotes/<origin>` file is used.
50 In order to determine what remote branches to fetch (and
51 optionally store in the tracking branches) when the command is
52 run without any refspec parameters on the command line, values
53 of the configuration variable `remote.<origin>.fetch` are
54 consulted, and if there aren't any, `$GIT_DIR/remotes/<origin>`
55 file is consulted and its `Pull: ` lines are used.
56 In addition to the refspec formats described in the OPTIONS
57 section, you can have a globbing refspec that looks like this:
60 refs/heads/*:refs/remotes/origin/*
63 A globbing refspec must have a non-empty RHS (i.e. must store
64 what were fetched in tracking branches), and its LHS and RHS
65 must end with `/*`. The above specifies that all remote
66 branches are tracked using tracking branches in
67 `refs/remotes/origin/` hierarchy under the same name.
69 The rule to determine which remote branch to merge after
70 fetching is a bit involved, in order not to break backward
73 If explicit refspecs were given on the command
74 line of `git pull`, they are all merged.
76 When no refspec was given on the command line, then `git pull`
77 uses the refspec from the configuration or
78 `$GIT_DIR/remotes/<origin>`. In such cases, the following
81 . If `branch.<name>.merge` configuration for the current
82 branch `<name>` exists, that is the name of the branch at the
83 remote site that is merged.
85 . If the refspec is a globbing one, nothing is merged.
87 . Otherwise the remote branch of the first refspec is merged.
93 git pull, git pull origin::
94 Update the remote-tracking branches for the repository
95 you cloned from, then merge one of them into your
96 current branch. Normally the branch merged in is
97 the HEAD of the remote repository, but the choice is
98 determined by the branch.<name>.remote and
99 branch.<name>.merge options; see gitlink:git-config[1]
102 git pull origin next::
103 Merge into the current branch the remote branch `next`;
104 leaves a copy of `next` temporarily in FETCH_HEAD, but
105 does not update any remote-tracking branches.
107 git pull . fixes enhancements::
108 Bundle local branch `fixes` and `enhancements` on top of
109 the current branch, making an Octopus merge. This `git pull .`
110 syntax is equivalent to `git merge`.
112 git pull -s ours . obsolete::
113 Merge local branch `obsolete` into the current branch,
114 using `ours` merge strategy.
116 git pull --no-commit . maint::
117 Merge local branch `maint` into the current branch, but
118 do not make a commit automatically. This can be used
119 when you want to include further changes to the merge,
120 or want to write your own merge commit message.
122 You should refrain from abusing this option to sneak substantial
123 changes into a merge commit. Small fixups like bumping
124 release/version name would be acceptable.
126 Command line pull of multiple branches from one repository::
128 ------------------------------------------------
129 $ git checkout master
130 $ git fetch origin +pu:pu maint:tmp
132 ------------------------------------------------
134 This updates (or creates, as necessary) branches `pu` and `tmp`
135 in the local repository by fetching from the branches
136 (respectively) `pu` and `maint` from the remote repository.
138 The `pu` branch will be updated even if it is does not
139 fast-forward; the others will not be.
141 The final command then merges the newly fetched `tmp` into master.
144 If you tried a pull which resulted in a complex conflicts and
145 would want to start over, you can recover with
146 gitlink:git-reset[1].
151 gitlink:git-fetch[1], gitlink:git-merge[1], gitlink:git-config[1]
156 Written by Linus Torvalds <torvalds@osdl.org>
157 and Junio C Hamano <junkio@cox.net>
161 Documentation by Jon Loeliger,
163 Junio C Hamano and the git-list <git@vger.kernel.org>.
167 Part of the gitlink:git[7] suite