Documentation / git-pull.txton commit Documentation/git-pull.txt: Add subtitles above included option files (3f7a9b5)
   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-------
  29
  30Options related to merging
  31~~~~~~~~~~~~~~~~~~~~~~~~~~
  32
  33include::merge-options.txt[]
  34
  35:git-pull: 1
  36
  37--rebase::
  38        Instead of a merge, perform a rebase after fetching.  If
  39        there is a remote ref for the upstream branch, and this branch
  40        was rebased since last fetched, the rebase uses that information
  41        to avoid rebasing non-local changes. To make this the default
  42        for branch `<name>`, set configuration `branch.<name>.rebase`
  43        to `true`.
  44+
  45[NOTE]
  46This is a potentially _dangerous_ mode of operation.
  47It rewrites history, which does not bode well when you
  48published that history already.  Do *not* use this option
  49unless you have read linkgit:git-rebase[1] carefully.
  50
  51--no-rebase::
  52        Override earlier --rebase.
  53
  54Options related to fetching
  55~~~~~~~~~~~~~~~~~~~~~~~~~~~
  56
  57include::fetch-options.txt[]
  58
  59include::pull-fetch-param.txt[]
  60
  61include::urls-remotes.txt[]
  62
  63include::merge-strategies.txt[]
  64
  65DEFAULT BEHAVIOUR
  66-----------------
  67
  68Often people use `git pull` without giving any parameter.
  69Traditionally, this has been equivalent to saying `git pull
  70origin`.  However, when configuration `branch.<name>.remote` is
  71present while on branch `<name>`, that value is used instead of
  72`origin`.
  73
  74In order to determine what URL to use to fetch from, the value
  75of the configuration `remote.<origin>.url` is consulted
  76and if there is not any such variable, the value on `URL: ` line
  77in `$GIT_DIR/remotes/<origin>` file is used.
  78
  79In order to determine what remote branches to fetch (and
  80optionally store in the tracking branches) when the command is
  81run without any refspec parameters on the command line, values
  82of the configuration variable `remote.<origin>.fetch` are
  83consulted, and if there aren't any, `$GIT_DIR/remotes/<origin>`
  84file is consulted and its `Pull: ` lines are used.
  85In addition to the refspec formats described in the OPTIONS
  86section, you can have a globbing refspec that looks like this:
  87
  88------------
  89refs/heads/*:refs/remotes/origin/*
  90------------
  91
  92A globbing refspec must have a non-empty RHS (i.e. must store
  93what were fetched in tracking branches), and its LHS and RHS
  94must end with `/*`.  The above specifies that all remote
  95branches are tracked using tracking branches in
  96`refs/remotes/origin/` hierarchy under the same name.
  97
  98The rule to determine which remote branch to merge after
  99fetching is a bit involved, in order not to break backward
 100compatibility.
 101
 102If explicit refspecs were given on the command
 103line of `git pull`, they are all merged.
 104
 105When no refspec was given on the command line, then `git pull`
 106uses the refspec from the configuration or
 107`$GIT_DIR/remotes/<origin>`.  In such cases, the following
 108rules apply:
 109
 110. If `branch.<name>.merge` configuration for the current
 111  branch `<name>` exists, that is the name of the branch at the
 112  remote site that is merged.
 113
 114. If the refspec is a globbing one, nothing is merged.
 115
 116. Otherwise the remote branch of the first refspec is merged.
 117
 118
 119EXAMPLES
 120--------
 121
 122* Update the remote-tracking branches for the repository
 123  you cloned from, then merge one of them into your
 124  current branch:
 125+
 126------------------------------------------------
 127$ git pull, git pull origin
 128------------------------------------------------
 129+
 130Normally the branch merged in is the HEAD of the remote repository,
 131but the choice is determined by the branch.<name>.remote and
 132branch.<name>.merge options; see linkgit:git-config[1] for details.
 133
 134* Merge into the current branch the remote branch `next`:
 135+
 136------------------------------------------------
 137$ git pull origin next
 138------------------------------------------------
 139+
 140This leaves a copy of `next` temporarily in FETCH_HEAD, but
 141does not update any remote-tracking branches.
 142
 143* Bundle local branch `fixes` and `enhancements` on top of
 144  the current branch, making an Octopus merge:
 145+
 146------------------------------------------------
 147$ git pull . fixes enhancements
 148------------------------------------------------
 149+
 150This `git pull .` syntax is equivalent to `git merge`.
 151
 152* Merge local branch `obsolete` into the current branch, using `ours`
 153  merge strategy:
 154+
 155------------------------------------------------
 156$ git pull -s ours . obsolete
 157------------------------------------------------
 158
 159* Merge local branch `maint` into the current branch, but do not make
 160  a commit automatically:
 161+
 162------------------------------------------------
 163$ git pull --no-commit . maint
 164------------------------------------------------
 165+
 166This can be used when you want to include further changes to the
 167merge, or want to write your own merge commit message.
 168+
 169You should refrain from abusing this option to sneak substantial
 170changes into a merge commit.  Small fixups like bumping
 171release/version name would be acceptable.
 172
 173* Command line pull of multiple branches from one repository:
 174+
 175------------------------------------------------
 176$ git checkout master
 177$ git fetch origin +pu:pu maint:tmp
 178$ git pull . tmp
 179------------------------------------------------
 180+
 181This updates (or creates, as necessary) branches `pu` and `tmp` in
 182the local repository by fetching from the branches (respectively)
 183`pu` and `maint` from the remote repository.
 184+
 185The `pu` branch will be updated even if it is does not fast-forward;
 186the others will not be.
 187+
 188The final command then merges the newly fetched `tmp` into master.
 189
 190
 191If you tried a pull which resulted in a complex conflicts and
 192would want to start over, you can recover with 'git-reset'.
 193
 194
 195SEE ALSO
 196--------
 197linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1]
 198
 199
 200Author
 201------
 202Written by Linus Torvalds <torvalds@osdl.org>
 203and Junio C Hamano <gitster@pobox.com>
 204
 205Documentation
 206--------------
 207Documentation by Jon Loeliger,
 208David Greaves,
 209Junio C Hamano and the git-list <git@vger.kernel.org>.
 210
 211GIT
 212---
 213Part of the linkgit:git[1] suite