Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/Documentation/git-pull.adoc # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / Documentation / git-pull.adoc` 242 lines ยท 8030 bytes Raw Blame History 1 git-pull(1) 2 =========== 3 4 NAME 5 ---- 6 git-pull - Fetch from and integrate with another repository or a local branch 7 8 9 SYNOPSIS 10 -------- 11 [synopsis] 12 git pull [] [ [...]] 13 14 15 DESCRIPTION 16 ----------- 17 18 Integrate changes from a remote repository into the current branch. 19 20 First, `git pull` runs `git fetch` with the same arguments 21 (excluding merge options) to fetch remote branch(es). 22 Then it decides which remote branch to integrate: if you run `git pull` 23 with no arguments this defaults to the <> 24 for the current branch. 25 Then it integrates that branch into the current branch. 26 27 There are 4 main options for integrating the remote branch: 28 29 1. `git pull --ff-only` will only do "fast-forward" updates: it 30 fails if your local branch has diverged from the remote branch. 31 This is the default. 32 2. `git pull --rebase` runs `git rebase` 33 3. `git pull --no-rebase` runs `git merge`. 34 4. `git pull --squash` runs `git merge --squash` 35 36 You can also set the configuration options `pull.rebase`, `pull.squash`, 37 or `pull.ff` with your preferred behaviour. 38 39 If there's a merge conflict during the merge or rebase that you don't 40 want to handle, you can safely abort it with `git merge --abort` or 41 `git rebase --abort`. See linkgit:gitmergeconflicts[7] 42 (or `git help mergeconflicts`) for a guide to handling merge conflicts. 43 44 OPTIONS 45 ------- 46 47 __:: 48 The "remote" repository to pull from. This can be either 49 a URL (see the section <> below) or the name 50 of a remote (see the section <> below). 51 + 52 Defaults to the configured upstream for the current branch, or `origin`. 53 See <> below for more on how to 54 configure upstreams. 55 56 __:: 57 Which branch or other reference(s) to fetch and integrate into the 58 current branch, for example `main` in `git pull origin main`. 59 Defaults to the configured upstream for the current branch. 60 + 61 This can be a branch, tag, or other collection of reference(s). 62 See <_>> below under "Options related to fetching" 63 for the full syntax, and <> below 64 for how `git pull` uses this argument to determine which remote branch 65 to integrate. 66 67 `-q`:: 68 `--quiet`:: 69 This is passed to both underlying git-fetch to squelch reporting of 70 during transfer, and underlying git-merge to squelch output during 71 merging. 72 73 `-v`:: 74 `--verbose`:: 75 Pass `--verbose` to git-fetch and git-merge. 76 77 `--recurse-submodules[=(yes|on-demand|no)]`:: 78 `--no-recurse-submodules`:: 79 This option controls if new commits of populated submodules should 80 be fetched, and if the working trees of active submodules should be 81 updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and 82 linkgit:gitmodules[5]). 83 + 84 If the checkout is done via rebase, local submodule commits are rebased as well. 85 + 86 If the update is done via merge, the submodule conflicts are resolved and checked out. 87 88 Options related to merging 89 ~~~~~~~~~~~~~~~~~~~~~~~~~~ 90 91 :git-pull: 1 92 93 include::merge-options.adoc[] 94 95 `-r`:: 96 `--rebase[=(true|merges|false|interactive)]`:: 97 `true`;; rebase the current branch on top of the upstream 98 branch after fetching. If there is a remote-tracking branch 99 corresponding to the upstream branch and the upstream branch 100 was rebased since last fetched, the rebase uses that information 101 to avoid rebasing non-local changes. This is the default. 102 103 `merges`;; rebase using `git rebase --rebase-merges` so that 104 the local merge commits are included in the rebase (see 105 linkgit:git-rebase[1] for details). 106 `false`;; merge the upstream branch into the current branch. 107 `interactive`;; enable the interactive mode of rebase. 108 109 + 110 See `pull.rebase`, `branch..rebase` and `branch.autoSetupRebase` in 111 linkgit:git-config[1] if you want to make `git pull` always use 112 `--rebase` instead of merging. 113 + 114 [NOTE] 115 This is a potentially _dangerous_ mode of operation. 116 It rewrites history, which does not bode well when you 117 published that history already. Do *not* use this option 118 unless you have read linkgit:git-rebase[1] carefully. 119 120 `--no-rebase`:: 121 This is shorthand for `--rebase=false`. 122 123 Options related to fetching 124 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 125 126 include::fetch-options.adoc[] 127 128 include::pull-fetch-param.adoc[] 129 130 include::urls-remotes.adoc[] 131 132 include::merge-strategies.adoc[] 133 134 [[DEFAULT-BEHAVIOUR]] 135 DEFAULT BEHAVIOUR 136 ----------------- 137 138 Often people use `git pull` without giving any parameter. 139 Traditionally, this has been equivalent to saying `git pull 140 origin`. However, when configuration `branch..remote` is 141 present while on branch ``, that value is used instead of 142 `origin`. 143 144 In order to determine what URL to use to fetch from, the value 145 of the configuration `remote..url` is consulted 146 and if there is not any such variable, the value on the `URL:` line 147 in `$GIT_DIR/remotes/` is used. 148 149 In order to determine what remote branches to fetch (and 150 optionally store in the remote-tracking branches) when the command is 151 run without any refspec parameters on the command line, values 152 of the configuration variable `remote..fetch` are 153 consulted, and if there aren't any, `$GIT_DIR/remotes/` 154 is consulted and its `Pull:` lines are used. 155 In addition to the refspec formats described in the OPTIONS 156 section, you can have a globbing refspec that looks like this: 157 158 ------------ 159 refs/heads/*:refs/remotes/origin/* 160 ------------ 161 162 A globbing refspec must have a non-empty RHS (i.e. must store 163 what were fetched in remote-tracking branches), and its LHS and RHS 164 must end with `/*`. The above specifies that all remote 165 branches are tracked using remote-tracking branches in 166 `refs/remotes/origin/` hierarchy under the same name. 167 168 The rule to determine which remote branch to merge after 169 fetching is a bit involved, in order not to break backward 170 compatibility. 171 172 If explicit refspecs were given on the command 173 line of `git pull`, they are all merged. 174 175 When no refspec was given on the command line, then `git pull` 176 uses the refspec from the configuration or 177 `$GIT_DIR/remotes/`. In such cases, the following 178 rules apply: 179 180 . If `branch..merge` configuration for the current 181 branch __ exists, that is the name of the branch at the 182 remote site that is merged. 183 184 . If the refspec is a globbing one, nothing is merged. 185 186 . Otherwise the remote branch of the first refspec is merged. 187 188 189 EXAMPLES 190 -------- 191 192 * Update the remote-tracking branches for the repository 193 you cloned from, then merge one of them into your 194 current branch: 195 + 196 ------------------------------------------------ 197 $ git pull 198 $ git pull origin 199 ------------------------------------------------ 200 + 201 Normally the branch merged in is the `HEAD` of the remote repository, 202 but the choice is determined by the `branch..remote` and 203 `branch..merge` options; see linkgit:git-config[1] for details. 204 205 * Merge into the current branch the remote branch `next`: 206 + 207 ------------------------------------------------ 208 $ git pull origin next 209 ------------------------------------------------ 210 + 211 This leaves a copy of `next` temporarily in `FETCH_HEAD`, and 212 updates the remote-tracking branch `origin/next`. 213 The same can be done by invoking fetch and merge: 214 + 215 ------------------------------------------------ 216 $ git fetch origin 217 $ git merge origin/next 218 ------------------------------------------------ 219 220 221 If you tried a pull which resulted in complex conflicts and 222 would want to start over, you can recover with `git reset`. 223 224 225 include::transfer-data-leaks.adoc[] 226 227 BUGS 228 ---- 229 Using `--recurse-submodules` can only fetch new commits in already checked 230 out submodules right now. When e.g. upstream added a new submodule in the 231 just fetched commits of the superproject the submodule itself cannot be 232 fetched, making it impossible to check out that submodule later without 233 having to do a fetch again. This is expected to be fixed in a future Git 234 version. 235 236 SEE ALSO 237 -------- 238 linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1] 239 240 GIT 241 --- 242 Part of the linkgit:git[1] suite