1git-pull(1) 2=========== 3 4NAME 5---- 6git-pull - Fetch from and merge with another repository or a local branch 7 8 9SYNOPSIS 10-------- 11'git pull' <options> <repository> <refspec>... 12 13 14DESCRIPTION 15----------- 16Runs 'git-fetch' with the given parameters, and calls 'git-merge' 17to merge the retrieved head(s) into the current branch. 18With `--rebase`, calls 'git-rebase' instead of 'git-merge'. 19 20Note that you can use `.` (current directory) as the 21<repository> to pull from the local repository -- this is useful 22when merging local branches into the current branch. 23 24Also note that options meant for 'git-pull' itself and underlying 25'git-merge' must be given before the options meant for 'git-fetch'. 26 27OPTIONS 28------- 29include::merge-options.txt[] 30 31:git-pull: 1 32 33--rebase:: 34 Instead of a merge, perform a rebase after fetching. If 35 there is a remote ref for the upstream branch, and this branch 36 was rebased since last fetched, the rebase uses that information 37 to avoid rebasing non-local changes. To make this the default 38 for branch `<name>`, set configuration `branch.<name>.rebase` 39 to `true`. 40+ 41[NOTE] 42This is a potentially _dangerous_ mode of operation. 43It rewrites history, which does not bode well when you 44published that history already. Do *not* use this option 45unless you have read linkgit:git-rebase[1] carefully. 46 47--no-rebase:: 48 Override earlier --rebase. 49 50include::fetch-options.txt[] 51 52include::pull-fetch-param.txt[] 53 54include::urls-remotes.txt[] 55 56include::merge-strategies.txt[] 57 58DEFAULT BEHAVIOUR 59----------------- 60 61Often people use `git pull` without giving any parameter. 62Traditionally, this has been equivalent to saying `git pull 63origin`. However, when configuration `branch.<name>.remote` is 64present while on branch `<name>`, that value is used instead of 65`origin`. 66 67In order to determine what URL to use to fetch from, the value 68of the configuration `remote.<origin>.url` is consulted 69and if there is not any such variable, the value on `URL: ` line 70in `$GIT_DIR/remotes/<origin>` file is used. 71 72In order to determine what remote branches to fetch (and 73optionally store in the tracking branches) when the command is 74run without any refspec parameters on the command line, values 75of the configuration variable `remote.<origin>.fetch` are 76consulted, and if there aren't any, `$GIT_DIR/remotes/<origin>` 77file is consulted and its `Pull: ` lines are used. 78In addition to the refspec formats described in the OPTIONS 79section, you can have a globbing refspec that looks like this: 80 81------------ 82refs/heads/*:refs/remotes/origin/* 83------------ 84 85A globbing refspec must have a non-empty RHS (i.e. must store 86what were fetched in tracking branches), and its LHS and RHS 87must end with `/*`. The above specifies that all remote 88branches are tracked using tracking branches in 89`refs/remotes/origin/` hierarchy under the same name. 90 91The rule to determine which remote branch to merge after 92fetching is a bit involved, in order not to break backward 93compatibility. 94 95If explicit refspecs were given on the command 96line of `git pull`, they are all merged. 97 98When no refspec was given on the command line, then `git pull` 99uses the refspec from the configuration or 100`$GIT_DIR/remotes/<origin>`. In such cases, the following 101rules apply: 102 103. If `branch.<name>.merge` configuration for the current 104 branch `<name>` exists, that is the name of the branch at the 105 remote site that is merged. 106 107. If the refspec is a globbing one, nothing is merged. 108 109. Otherwise the remote branch of the first refspec is merged. 110 111 112EXAMPLES 113-------- 114 115* Update the remote-tracking branches for the repository 116 you cloned from, then merge one of them into your 117 current branch: 118+ 119------------------------------------------------ 120$ git pull, git pull origin 121------------------------------------------------ 122+ 123Normally the branch merged in is the HEAD of the remote repository, 124but the choice is determined by the branch.<name>.remote and 125branch.<name>.merge options; see linkgit:git-config[1] for details. 126 127* Merge into the current branch the remote branch `next`: 128+ 129------------------------------------------------ 130$ git pull origin next 131------------------------------------------------ 132+ 133This leaves a copy of `next` temporarily in FETCH_HEAD, but 134does not update any remote-tracking branches. Using remote-tracking 135branches, the same can be done by invoking fetch and merge: 136+ 137------------------------------------------------ 138$ git fetch origin 139$ git merge origin/next 140------------------------------------------------ 141 142 143If you tried a pull which resulted in a complex conflicts and 144would want to start over, you can recover with 'git-reset'. 145 146 147SEE ALSO 148-------- 149linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1] 150 151 152Author 153------ 154Written by Linus Torvalds <torvalds@osdl.org> 155and Junio C Hamano <gitster@pobox.com> 156 157Documentation 158-------------- 159Documentation by Jon Loeliger, 160David Greaves, 161Junio C Hamano and the git-list <git@vger.kernel.org>. 162 163GIT 164--- 165Part of the linkgit:git[1] suite