fetch doc: move FETCH_HEAD material lower and add an example
[git.git] / Documentation / git-fetch.txt
blob06106b9b0c57d137f425154e71ac3d20ca0c9c22
1 git-fetch(1)
2 ============
4 NAME
5 ----
6 git-fetch - Download objects and refs from another repository
9 SYNOPSIS
10 --------
11 [verse]
12 'git fetch' [<options>] [<repository> [<refspec>...]]
13 'git fetch' [<options>] <group>
14 'git fetch' --multiple [<options>] [(<repository> | <group>)...]
15 'git fetch' --all [<options>]
18 DESCRIPTION
19 -----------
20 Fetch branches and/or tags (collectively, "refs") from one or more
21 other repositories, along with the objects necessary to complete their
22 histories.  Remote-tracking branches are updated (see the description
23 of <refspec> below for ways to control this behavior).
25 By default, any tag that points into the histories being fetched is
26 also fetched; the effect is to fetch tags that
27 point at branches that you are interested in.  This default behavior
28 can be changed by using the --tags or --no-tags options or by
29 configuring remote.<name>.tagopt.  By using a refspec that fetches tags
30 explicitly, you can fetch tags that do not point into branches you
31 are interested in as well.
33 'git fetch' can fetch from either a single named repository or URL,
34 or from several repositories at once if <group> is given and
35 there is a remotes.<group> entry in the configuration file.
36 (See linkgit:git-config[1]).
38 When no remote is specified, by default the `origin` remote will be used,
39 unless there's an upstream branch configured for the current branch.
41 The names of refs that are fetched, together with the object names
42 they point at, are written to `.git/FETCH_HEAD`.  This information
43 may be used by scripts or other git commands, such as linkgit:git-pull[1].
45 OPTIONS
46 -------
47 include::fetch-options.txt[]
49 include::pull-fetch-param.txt[]
51 include::urls-remotes.txt[]
54 EXAMPLES
55 --------
57 * Update the remote-tracking branches:
59 ------------------------------------------------
60 $ git fetch origin
61 ------------------------------------------------
63 The above command copies all branches from the remote refs/heads/
64 namespace and stores them to the local refs/remotes/origin/ namespace,
65 unless the branch.<name>.fetch option is used to specify a non-default
66 refspec.
68 * Using refspecs explicitly:
70 ------------------------------------------------
71 $ git fetch origin +pu:pu maint:tmp
72 ------------------------------------------------
74 This updates (or creates, as necessary) branches `pu` and `tmp` in
75 the local repository by fetching from the branches (respectively)
76 `pu` and `maint` from the remote repository.
78 The `pu` branch will be updated even if it is does not fast-forward,
79 because it is prefixed with a plus sign; `tmp` will not be.
81 * Peek at a remote's branch, without configuring the remote in your local
82 repository:
84 ------------------------------------------------
85 $ git fetch git://git.kernel.org/pub/scm/git/git.git maint
86 $ git log FETCH_HEAD
87 ------------------------------------------------
89 The first command fetches the `maint` branch from the repository at
90 `git://git.kernel.org/pub/scm/git/git.git` and the second command uses
91 `FETCH_HEAD` to examine the branch with linkgit:git-log[1].  The fetched
92 objects will eventually be removed by git's built-in housekeeping (see
93 linkgit:git-gc[1]).
95 BUGS
96 ----
97 Using --recurse-submodules can only fetch new commits in already checked
98 out submodules right now. When e.g. upstream added a new submodule in the
99 just fetched commits of the superproject the submodule itself can not be
100 fetched, making it impossible to check out that submodule later without
101 having to do a fetch again. This is expected to be fixed in a future Git
102 version.
104 SEE ALSO
105 --------
106 linkgit:git-pull[1]
110 Part of the linkgit:git[1] suite