1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.2.5" />
7 <style type=
"text/css">
9 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
11 border: 1px solid red;
16 margin: 1em 5% 1em 5%;
21 text-decoration: underline
;
39 h1
, h2
, h3
, h4
, h5
, h6
{
41 font-family: sans-serif
;
48 border-bottom: 2px solid silver
;
66 border: 1px solid silver
;
81 font-family: sans-serif
;
88 font-family: sans-serif
;
92 font-family: sans-serif
;
94 border-top: 2px solid silver
;
100 padding-bottom: 0.5em;
104 padding-bottom: 0.5em;
108 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
109 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
110 div
.admonitionblock
{
113 margin-bottom: 1.5em;
115 div
.admonitionblock
{
117 margin-bottom: 2.5em;
120 div
.content
{ /* Block element content. */
124 /* Block element titles. */
125 div
.title
, caption
.title
{
126 font-family: sans-serif
;
130 margin-bottom: 0.5em;
136 td div
.title:first-child
{
139 div
.content div
.title:first-child
{
142 div
.content
+ div
.title
{
146 div
.sidebarblock
> div
.content
{
148 border: 1px solid silver
;
155 div
.listingblock
> div
.content
{
156 border: 1px solid silver
;
161 div
.quoteblock
> div
.content
{
168 div
.verseblock
+ div
.attribution
{
172 div
.admonitionblock
.icon
{
176 text-decoration: underline
;
178 padding-right: 0.5em;
180 div
.admonitionblock td
.content
{
182 border-left: 2px solid silver
;
185 div
.exampleblock
> div
.content
{
186 border-left: 2px solid silver
;
190 div
.verseblock div
.content
{
194 div
.imageblock div
.content
{ padding-left: 0; }
195 div
.imageblock img
{ border: 1px solid silver
; }
196 span
.image img
{ border-style: none
; }
200 margin-bottom: 0.8em;
212 list-style-position: outside
;
215 list-style-type: lower-alpha
;
218 div
.tableblock
> table
{
219 border: 3px solid
#527bbd;
222 font-family: sans-serif
;
231 margin-bottom: 0.8em;
239 padding-right: 0.8em;
246 div#footer-badges
{ display: none
; }
251 font-family: sans-serif
;
255 margin-bottom: 0.1em;
258 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
274 include1::./stylesheets
/xhtml11-manpage
.css
[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div
.sidebar-content
{
279 border: 1px solid silver
;
282 div
.sidebar-title
, div
.image-title
{
283 font-family: sans-serif
;
286 margin-bottom: 0.5em;
289 div
.listingblock div
.content
{
290 border: 1px solid silver
;
295 div
.quoteblock-content
{
299 div
.exampleblock-content
{
300 border-left: 2px solid silver
;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc
a:visited
{ color: blue
; }
307 <title>git-fetch(
1)
</title>
312 git-fetch(
1) Manual Page
315 <div class=
"sectionbody">
317 Download objects and refs from another repository
322 <div class=
"sectionbody">
323 <div class=
"para"><p><em>git fetch
</em> <options
> <repository
> <refspec
>…</p></div>
325 <h2 id=
"_description">DESCRIPTION
</h2>
326 <div class=
"sectionbody">
327 <div class=
"para"><p>Fetches named heads or tags from another repository, along with
328 the objects necessary to complete them.
</p></div>
329 <div class=
"para"><p>The ref names and their object names of fetched refs are stored
330 in
<tt>.git/FETCH_HEAD
</tt>. This information is left for a later merge
331 operation done by
<em>git-merge
</em>.
</p></div>
332 <div class=
"para"><p>When
<refspec
> stores the fetched result in tracking branches,
333 the tags that point at these branches are automatically
334 followed. This is done by first fetching from the remote using
335 the given
<refspec
>s, and if the repository has objects that are
336 pointed by remote tags that it does not yet have, then fetch
337 those missing tags. If the other end has tags that point at
338 branches you are not interested in, you will not get them.
</p></div>
340 <h2 id=
"_options">OPTIONS
</h2>
341 <div class=
"sectionbody">
342 <div class=
"vlist"><dl>
351 Pass --quiet to git-fetch-pack and silence any other internally
374 Append ref names and object names of fetched refs to the
375 existing contents of
<tt>.git/FETCH_HEAD
</tt>. Without this
376 option old data in
<tt>.git/FETCH_HEAD
</tt> will be overwritten.
380 --upload-pack
<upload-pack
>
384 When given, and the repository to fetch from is handled
385 by
<em>git-fetch-pack
</em>,
<em>--exec=
<upload-pack
></em> is passed to
386 the command to specify non-default path for the command
387 run on the other end.
398 When
<em>git-fetch
</em> is used with
<tt><rbranch
>:
<lbranch
></tt>
399 refspec, it refuses to update the local branch
400 <tt><lbranch
></tt> unless the remote branch
<tt><rbranch
></tt> it
401 fetches is a descendant of
<tt><lbranch
></tt>. This option
402 overrides that check.
413 By default, tags that point at objects that are downloaded
414 from the remote repository are fetched and stored locally.
415 This option disables this automatic tag following.
426 Most of the tags are fetched automatically as branch
427 heads are downloaded, but tags that do not point at
428 objects reachable from the branch heads that are being
429 tracked will not be fetched by this mechanism. This
430 flag lets all tags and their associated objects be
442 Keep downloaded pack.
453 By default
<em>git-fetch
</em> refuses to update the head which
454 corresponds to the current branch. This flag disables the
455 check. This is purely for the internal use for
<em>git-pull
</em>
456 to communicate with
<em>git-fetch
</em>, and unless you are
457 implementing your own Porcelain you are not supposed to
462 --depth=
<depth
>
466 Deepen the history of a
<em>shallow
</em> repository created by
467 <tt>git clone
</tt> with
<tt>--depth=
<depth
></tt> option (see
<a href=
"git-clone.html">git-clone(
1)
</a>)
468 by the specified number of commits.
476 The
"remote" repository that is the source of a fetch
477 or pull operation. This parameter can be either a URL
478 (see the section
<a href=
"#URLS">GIT URLS
</a> below) or the name
479 of a remote (see the section
<a href=
"#REMOTES">REMOTES
</a> below).
487 The format of a
<refspec
> parameter is an optional plus
488 <tt>+</tt>, followed by the source ref
<src
>, followed
489 by a colon
<tt>:
</tt>, followed by the destination ref
<dst
>.
491 <div class=
"para"><p>The remote ref that matches
<src
>
492 is fetched, and if
<dst
> is not empty string, the local
493 ref that matches it is fast forwarded using
<src
>.
494 If the optional plus
<tt>+
</tt> is used, the local ref
495 is updated even if it does not result in a fast forward
497 <div class=
"admonitionblock">
500 <div class=
"title">Note
</div>
502 <td class=
"content">If the remote branch from which you want to pull is
503 modified in non-linear ways such as being rewound and
504 rebased frequently, then a pull will attempt a merge with
505 an older version of itself, likely conflict, and fail.
506 It is under these conditions that you would want to use
507 the
<tt>+
</tt> sign to indicate non-fast-forward updates will
508 be needed. There is currently no easy way to determine
509 or declare that a branch will be made available in a
510 repository with this behavior; the pulling user simply
511 must know this is the expected usage pattern for a branch.
</td>
514 <div class=
"admonitionblock">
517 <div class=
"title">Note
</div>
519 <td class=
"content">You never do your own development on branches that appear
520 on the right hand side of a
<refspec
> colon on
<tt>Pull:
</tt> lines;
521 they are to be updated by
<em>git-fetch
</em>. If you intend to do
522 development derived from a remote branch
<tt>B
</tt>, have a
<tt>Pull:
</tt>
523 line to track it (i.e.
<tt>Pull: B:remote-B
</tt>), and have a separate
524 branch
<tt>my-B
</tt> to do your development on top of it. The latter
525 is created by
<tt>git branch my-B remote-B
</tt> (or its equivalent
<tt>git
526 checkout -b my-B remote-B
</tt>). Run
<tt>git fetch
</tt> to keep track of
527 the progress of the remote side, and when you see something new
528 on the remote branch, merge it into your development branch with
529 <tt>git pull . remote-B
</tt>, while you are on
<tt>my-B
</tt> branch.
</td>
532 <div class=
"admonitionblock">
535 <div class=
"title">Note
</div>
537 <td class=
"content">There is a difference between listing multiple
<refspec
>
538 directly on
<em>git-pull
</em> command line and having multiple
539 <tt>Pull:
</tt> <refspec
> lines for a
<repository
> and running
540 <em>git-pull
</em> command without any explicit
<refspec
> parameters.
541 <refspec
> listed explicitly on the command line are always
542 merged into the current branch after fetching. In other words,
543 if you list more than one remote refs, you would be making
544 an Octopus. While
<em>git-pull
</em> run without any explicit
<refspec
>
545 parameter takes default
<refspec
>s from
<tt>Pull:
</tt> lines, it
546 merges only the first
<refspec
> found into the current branch,
547 after fetching all the remote refs. This is because making an
548 Octopus from remote refs is rarely done, while keeping track
549 of multiple remote heads in one-go by fetching more than one
550 is often useful.
</td>
553 <div class=
"para"><p>Some short-cut notations are also supported.
</p></div>
554 <div class=
"ilist"><ul>
557 <tt>tag
<tag
></tt> means the same as
<tt>refs/tags/
<tag
>:refs/tags/
<tag
></tt>;
558 it requests fetching everything up to the given tag.
563 A parameter
<ref
> without a colon is equivalent to
564 <ref
>: when pulling/fetching, so it merges
<ref
> into the current
565 branch without storing the remote branch anywhere locally
572 <h2 id=
"_git_urls_a_id_urls_a">GIT URLS
<a id=
"URLS"></a></h2>
573 <div class=
"sectionbody">
574 <div class=
"para"><p>One of the following notations can be used
575 to name the remote repository:
</p></div>
576 <div class=
"exampleblock">
577 <div class=
"exampleblock-content">
578 <div class=
"ilist"><ul>
581 rsync://host.xz/path/to/repo.git/
586 http://host.xz
[:port
]/path/to/repo.git/
591 https://host.xz
[:port
]/path/to/repo.git/
596 git://host.xz
[:port
]/path/to/repo.git/
601 git://host.xz
[:port
]/~user/path/to/repo.git/
606 ssh://
[user@
]host.xz
[:port
]/path/to/repo.git/
611 ssh://
[user@
]host.xz/path/to/repo.git/
616 ssh://
[user@
]host.xz/~user/path/to/repo.git/
621 ssh://
[user@
]host.xz/~/path/to/repo.git
626 <div class=
"para"><p>SSH is the default transport protocol over the network. You can
627 optionally specify which user to log-in as, and an alternate,
628 scp-like syntax is also supported. Both syntaxes support
629 username expansion, as does the native git protocol, but
630 only the former supports port specification. The following
631 three are identical to the last three above, respectively:
</p></div>
632 <div class=
"exampleblock">
633 <div class=
"exampleblock-content">
634 <div class=
"ilist"><ul>
637 [user@
]host.xz:/path/to/repo.git/
642 [user@
]host.xz:~user/path/to/repo.git/
647 [user@
]host.xz:path/to/repo.git
652 <div class=
"para"><p>To sync with a local directory, you can use:
</p></div>
653 <div class=
"exampleblock">
654 <div class=
"exampleblock-content">
655 <div class=
"ilist"><ul>
663 file:///path/to/repo.git/
668 <div class=
"para"><p>They are mostly equivalent, except when cloning. See
669 <a href=
"git-clone.html">git-clone(
1)
</a> for details.
</p></div>
670 <div class=
"para"><p>If there are a large number of similarly-named remote repositories and
671 you want to use a different format for them (such that the URLs you
672 use will be rewritten into URLs that work), you can create a
673 configuration section of the form:
</p></div>
674 <div class=
"listingblock">
675 <div class=
"content">
676 <pre><tt> [url
"<actual url base>"]
677 insteadOf =
<other url base
></tt></pre>
679 <div class=
"para"><p>For example, with this:
</p></div>
680 <div class=
"listingblock">
681 <div class=
"content">
682 <pre><tt> [url
"git://git.host.xz/"]
683 insteadOf = host.xz:/path/to/
684 insteadOf = work:
</tt></pre>
686 <div class=
"para"><p>a URL like
"work:repo.git" or like
"host.xz:/path/to/repo.git" will be
687 rewritten in any context that takes a URL to be
"git://git.host.xz/repo.git".
</p></div>
689 <h2 id=
"_remotes_a_id_remotes_a">REMOTES
<a id=
"REMOTES"></a></h2>
690 <div class=
"sectionbody">
691 <div class=
"para"><p>The name of one of the following can be used instead
692 of a URL as
<tt><repository
></tt> argument:
</p></div>
693 <div class=
"ilist"><ul>
696 a remote in the git configuration file:
<tt>$GIT_DIR/config
</tt>,
701 a file in the
<tt>$GIT_DIR/remotes
</tt> directory, or
706 a file in the
<tt>$GIT_DIR/branches
</tt> directory.
710 <div class=
"para"><p>All of these also allow you to omit the refspec from the command line
711 because they each contain a refspec which git will use by default.
</p></div>
712 <h3 id=
"_named_remote_in_configuration_file">Named remote in configuration file
</h3><div style=
"clear:left"></div>
713 <div class=
"para"><p>You can choose to provide the name of a remote which you had previously
714 configured using
<a href=
"git-remote.html">git-remote(
1)
</a>,
<a href=
"git-config.html">git-config(
1)
</a>
715 or even by a manual edit to the
<tt>$GIT_DIR/config
</tt> file. The URL of
716 this remote will be used to access the repository. The refspec
717 of this remote will be used by default when you do
718 not provide a refspec on the command line. The entry in the
719 config file would appear like this:
</p></div>
720 <div class=
"listingblock">
721 <div class=
"content">
722 <pre><tt> [remote
"<name>"]
724 push =
<refspec
>
725 fetch =
<refspec
></tt></pre>
727 <h3 id=
"_named_file_in_tt_git_dir_remotes_tt">Named file in
<tt>$GIT_DIR/remotes
</tt></h3><div style=
"clear:left"></div>
728 <div class=
"para"><p>You can choose to provide the name of a
729 file in
<tt>$GIT_DIR/remotes
</tt>. The URL
730 in this file will be used to access the repository. The refspec
731 in this file will be used as default when you do not
732 provide a refspec on the command line. This file should have the
733 following format:
</p></div>
734 <div class=
"listingblock">
735 <div class=
"content">
736 <pre><tt> URL: one of the above URL format
737 Push:
<refspec
>
738 Pull:
<refspec
>
741 <div class=
"para"><p><tt>Push:
</tt> lines are used by
<em>git-push
</em> and
742 <tt>Pull:
</tt> lines are used by
<em>git-pull
</em> and
<em>git-fetch
</em>.
743 Multiple
<tt>Push:
</tt> and
<tt>Pull:
</tt> lines may
744 be specified for additional branch mappings.
</p></div>
745 <h3 id=
"_named_file_in_tt_git_dir_branches_tt">Named file in
<tt>$GIT_DIR/branches
</tt></h3><div style=
"clear:left"></div>
746 <div class=
"para"><p>You can choose to provide the name of a
747 file in
<tt>$GIT_DIR/branches
</tt>.
748 The URL in this file will be used to access the repository.
749 This file should have the following format:
</p></div>
750 <div class=
"listingblock">
751 <div class=
"content">
752 <pre><tt> <url
>#
<head
></tt></pre>
754 <div class=
"para"><p><tt><url
></tt> is required;
<tt>#
<head
></tt> is optional.
</p></div>
755 <div class=
"para"><p>Depending on the operation, git will use one of the following
756 refspecs, if you don't provide one on the command line.
757 <tt><branch
></tt> is the name of this file in
<tt>$GIT_DIR/branches
</tt> and
758 <tt><head
></tt> defaults to
<tt>master
</tt>.
</p></div>
759 <div class=
"para"><p>git fetch uses:
</p></div>
760 <div class=
"listingblock">
761 <div class=
"content">
762 <pre><tt> refs/heads/
<head
>:refs/heads/
<branch
></tt></pre>
764 <div class=
"para"><p>git push uses:
</p></div>
765 <div class=
"listingblock">
766 <div class=
"content">
767 <pre><tt> HEAD:refs/heads/
<head
></tt></pre>
770 <h2 id=
"_see_also">SEE ALSO
</h2>
771 <div class=
"sectionbody">
772 <div class=
"para"><p><a href=
"git-pull.html">git-pull(
1)
</a></p></div>
774 <h2 id=
"_author">Author
</h2>
775 <div class=
"sectionbody">
776 <div class=
"para"><p>Written by Linus Torvalds
<torvalds@osdl.org
> and
777 Junio C Hamano
<gitster@pobox.com
></p></div>
779 <h2 id=
"_documentation">Documentation
</h2>
780 <div class=
"sectionbody">
781 <div class=
"para"><p>Documentation by David Greaves, Junio C Hamano and the git-list
<git@vger.kernel.org
>.
</p></div>
783 <h2 id=
"_git">GIT
</h2>
784 <div class=
"sectionbody">
785 <div class=
"para"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
788 <div id=
"footer-text">
789 Last updated
2009-
04-
02 06:
49:
52 UTC