Skip to content

Commit 366a018

Browse files
marcnarcgitster
authored andcommitted
fetch doc: move FETCH_HEAD material lower and add an example
Signed-off-by: Marc Branchaud <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5328456 commit 366a018

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

Documentation/git-fetch.txt

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@ SYNOPSIS
1818
DESCRIPTION
1919
-----------
2020
Fetch branches and/or tags (collectively, "refs") from one or more
21-
other repositories, along with the objects necessary to complete
22-
their histories.
23-
24-
The names of refs that are fetched, together with the object names
25-
they point at, are written to `.git/FETCH_HEAD`. This information
26-
can be used to learn what was fetched. In addition, the remote-tracking
27-
branches are updated (see description on <refspec> below for details).
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).
2824

2925
By default, any tag that points into the histories being fetched is
3026
also fetched; the effect is to fetch tags that
@@ -34,14 +30,18 @@ configuring remote.<name>.tagopt. By using a refspec that fetches tags
3430
explicitly, you can fetch tags that do not point into branches you
3531
are interested in as well.
3632

37-
'git fetch' can fetch from either a single named repository,
33+
'git fetch' can fetch from either a single named repository or URL,
3834
or from several repositories at once if <group> is given and
3935
there is a remotes.<group> entry in the configuration file.
4036
(See linkgit:git-config[1]).
4137

4238
When no remote is specified, by default the `origin` remote will be used,
4339
unless there's an upstream branch configured for the current branch.
4440

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].
44+
4545
OPTIONS
4646
-------
4747
include::fetch-options.txt[]
@@ -78,6 +78,19 @@ the local repository by fetching from the branches (respectively)
7878
The `pu` branch will be updated even if it is does not fast-forward,
7979
because it is prefixed with a plus sign; `tmp` will not be.
8080

81+
* Peek at a remote's branch, without configuring the remote in your local
82+
repository:
83+
+
84+
------------------------------------------------
85+
$ git fetch git://git.kernel.org/pub/scm/git/git.git maint
86+
$ git log FETCH_HEAD
87+
------------------------------------------------
88+
+
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]).
8194

8295
BUGS
8396
----

0 commit comments

Comments
 (0)