Documentation / git-pull.txton commit Documentation/gitdiffcore: Remove misleading date in heading (dddfb3f)
   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. Using remote-tracking
 142branches, the same can be done by invoking fetch and merge:
 143+
 144------------------------------------------------
 145$ git fetch origin
 146$ git merge origin/next
 147------------------------------------------------
 148
 149
 150If you tried a pull which resulted in a complex conflicts and
 151would want to start over, you can recover with 'git-reset'.
 152
 153
 154SEE ALSO
 155--------
 156linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1]
 157
 158
 159Author
 160------
 161Written by Linus Torvalds <torvalds@osdl.org>
 162and Junio C Hamano <gitster@pobox.com>
 163
 164Documentation
 165--------------
 166Documentation by Jon Loeliger,
 167David Greaves,
 168Junio C Hamano and the git-list <git@vger.kernel.org>.
 169
 170GIT
 171---
 172Part of the linkgit:git[1] suite