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