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