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>
324 <div class=
"para"><p><em>git fetch
</em> [
<options
>]
<group
></p></div>
325 <div class=
"para"><p><em>git fetch
</em> --multiple [
<options
>] [
<repository
> |
<group
>]
…</p></div>
326 <div class=
"para"><p><em>git fetch
</em> --all [
<options
>]
</p></div>
328 <h2 id=
"_description">DESCRIPTION
</h2>
329 <div class=
"sectionbody">
330 <div class=
"para"><p>Fetches named heads or tags from one or more other repositories,
331 along with the objects necessary to complete them.
</p></div>
332 <div class=
"para"><p>The ref names and their object names of fetched refs are stored
333 in
<tt>.git/FETCH_HEAD
</tt>. This information is left for a later merge
334 operation done by
<em>git merge
</em>.
</p></div>
335 <div class=
"para"><p>When
<refspec
> stores the fetched result in tracking branches,
336 the tags that point at these branches are automatically
337 followed. This is done by first fetching from the remote using
338 the given
<refspec
>s, and if the repository has objects that are
339 pointed by remote tags that it does not yet have, then fetch
340 those missing tags. If the other end has tags that point at
341 branches you are not interested in, you will not get them.
</p></div>
342 <div class=
"para"><p><em>git fetch
</em> can fetch from either a single named repository, or
343 or from several repositories at once if
<group
> is given and
344 there is a remotes.
<group
> entry in the configuration file.
345 (See
<a href=
"git-config.html">git-config(
1)
</a>).
</p></div>
347 <h2 id=
"_options">OPTIONS
</h2>
348 <div class=
"sectionbody">
349 <div class=
"vlist"><dl>
366 Append ref names and object names of fetched refs to the
367 existing contents of
<tt>.git/FETCH_HEAD
</tt>. Without this
368 option old data in
<tt>.git/FETCH_HEAD
</tt> will be overwritten.
372 --depth=
<depth
>
376 Deepen the history of a
<em>shallow
</em> repository created by
377 <tt>git clone
</tt> with
<tt>--depth=
<depth
></tt> option (see
<a href=
"git-clone.html">git-clone(
1)
</a>)
378 by the specified number of commits.
386 Show what would be done, without making any changes.
397 When
<em>git fetch
</em> is used with
<tt><rbranch
>:
<lbranch
></tt>
398 refspec, it refuses to update the local branch
399 <tt><lbranch
></tt> unless the remote branch
<tt><rbranch
></tt> it
400 fetches is a descendant of
<tt><lbranch
></tt>. This option
401 overrides that check.
412 Keep downloaded pack.
420 Allow several
<repository
> and
<group
> arguments to be
421 specified. No
<refspec
>s may be specified.
429 After fetching, remove any remote tracking branches which
430 no longer exist on the remote.
441 By default, tags that point at objects that are downloaded
442 from the remote repository are fetched and stored locally.
443 This option disables this automatic tag following.
454 Most of the tags are fetched automatically as branch
455 heads are downloaded, but tags that do not point at
456 objects reachable from the branch heads that are being
457 tracked will not be fetched by this mechanism. This
458 flag lets all tags and their associated objects be
470 By default
<em>git fetch
</em> refuses to update the head which
471 corresponds to the current branch. This flag disables the
472 check. This is purely for the internal use for
<em>git pull
</em>
473 to communicate with
<em>git fetch
</em>, and unless you are
474 implementing your own Porcelain you are not supposed to
479 --upload-pack
<upload-pack
>
483 When given, and the repository to fetch from is handled
484 by
<em>git fetch-pack
</em>,
<em>--exec=
<upload-pack
></em> is passed to
485 the command to specify non-default path for the command
486 run on the other end.
497 Pass --quiet to git-fetch-pack and silence any other internally
498 used git commands. Progress is not reported to the standard error
518 Progress status is reported on the standard error stream
519 by default when it is attached to a terminal, unless -q
520 is specified. This flag forces progress status even if the
521 standard error stream is not directed to a terminal.
529 The
"remote" repository that is the source of a fetch
530 or pull operation. This parameter can be either a URL
531 (see the section
<a href=
"#URLS">GIT URLS
</a> below) or the name
532 of a remote (see the section
<a href=
"#REMOTES">REMOTES
</a> below).
540 A name referring to a list of repositories as the value
541 of remotes.
<group
> in the configuration file.
542 (See
<a href=
"git-config.html">git-config(
1)
</a>).
550 The format of a
<refspec
> parameter is an optional plus
551 <tt>+</tt>, followed by the source ref
<src
>, followed
552 by a colon
<tt>:
</tt>, followed by the destination ref
<dst
>.
554 <div class=
"para"><p>The remote ref that matches
<src
>
555 is fetched, and if
<dst
> is not empty string, the local
556 ref that matches it is fast-forwarded using
<src
>.
557 If the optional plus
<tt>+
</tt> is used, the local ref
558 is updated even if it does not result in a fast-forward
560 <div class=
"admonitionblock">
563 <div class=
"title">Note
</div>
565 <td class=
"content">If the remote branch from which you want to pull is
566 modified in non-linear ways such as being rewound and
567 rebased frequently, then a pull will attempt a merge with
568 an older version of itself, likely conflict, and fail.
569 It is under these conditions that you would want to use
570 the
<tt>+
</tt> sign to indicate non-fast-forward updates will
571 be needed. There is currently no easy way to determine
572 or declare that a branch will be made available in a
573 repository with this behavior; the pulling user simply
574 must know this is the expected usage pattern for a branch.
</td>
577 <div class=
"admonitionblock">
580 <div class=
"title">Note
</div>
582 <td class=
"content">You never do your own development on branches that appear
583 on the right hand side of a
<refspec
> colon on
<tt>Pull:
</tt> lines;
584 they are to be updated by
<em>git fetch
</em>. If you intend to do
585 development derived from a remote branch
<tt>B
</tt>, have a
<tt>Pull:
</tt>
586 line to track it (i.e.
<tt>Pull: B:remote-B
</tt>), and have a separate
587 branch
<tt>my-B
</tt> to do your development on top of it. The latter
588 is created by
<tt>git branch my-B remote-B
</tt> (or its equivalent
<tt>git
589 checkout -b my-B remote-B
</tt>). Run
<tt>git fetch
</tt> to keep track of
590 the progress of the remote side, and when you see something new
591 on the remote branch, merge it into your development branch with
592 <tt>git pull . remote-B
</tt>, while you are on
<tt>my-B
</tt> branch.
</td>
595 <div class=
"admonitionblock">
598 <div class=
"title">Note
</div>
600 <td class=
"content">There is a difference between listing multiple
<refspec
>
601 directly on
<em>git pull
</em> command line and having multiple
602 <tt>Pull:
</tt> <refspec
> lines for a
<repository
> and running
603 <em>git pull
</em> command without any explicit
<refspec
> parameters.
604 <refspec
> listed explicitly on the command line are always
605 merged into the current branch after fetching. In other words,
606 if you list more than one remote refs, you would be making
607 an Octopus. While
<em>git pull
</em> run without any explicit
<refspec
>
608 parameter takes default
<refspec
>s from
<tt>Pull:
</tt> lines, it
609 merges only the first
<refspec
> found into the current branch,
610 after fetching all the remote refs. This is because making an
611 Octopus from remote refs is rarely done, while keeping track
612 of multiple remote heads in one-go by fetching more than one
613 is often useful.
</td>
616 <div class=
"para"><p>Some short-cut notations are also supported.
</p></div>
617 <div class=
"ilist"><ul>
620 <tt>tag
<tag
></tt> means the same as
<tt>refs/tags/
<tag
>:refs/tags/
<tag
></tt>;
621 it requests fetching everything up to the given tag.
626 A parameter
<ref
> without a colon is equivalent to
627 <ref
>: when pulling/fetching, so it merges
<ref
> into the current
628 branch without storing the remote branch anywhere locally
635 <h2 id=
"_git_urls_a_id_urls_a">GIT URLS
<a id=
"URLS"></a></h2>
636 <div class=
"sectionbody">
637 <div class=
"para"><p>In general, URLs contain information about the transport protocol, the
638 address of the remote server, and the path to the repository.
639 Depending on the transport protocol, some of this information may be
641 <div class=
"para"><p>Git natively supports ssh, git, http, https, ftp, ftps, and rsync
642 protocols. The following syntaxes may be used with them:
</p></div>
643 <div class=
"ilist"><ul>
646 ssh://
[user@
]host.xz
[:port
]/path/to/repo.git/
651 git://host.xz
[:port
]/path/to/repo.git/
656 http
[s
]://host.xz
[:port
]/path/to/repo.git/
661 ftp
[s
]://host.xz
[:port
]/path/to/repo.git/
666 rsync://host.xz/path/to/repo.git/
670 <div class=
"para"><p>An alternative scp-like syntax may also be used with the ssh protocol:
</p></div>
671 <div class=
"ilist"><ul>
674 [user@
]host.xz:path/to/repo.git/
678 <div class=
"para"><p>The ssh and git protocols additionally support ~username expansion:
</p></div>
679 <div class=
"ilist"><ul>
682 ssh://
[user@
]host.xz
[:port
]/~
[user
]/path/to/repo.git/
687 git://host.xz
[:port
]/~
[user
]/path/to/repo.git/
692 [user@
]host.xz:/~
[user
]/path/to/repo.git/
696 <div class=
"para"><p>For local respositories, also supported by git natively, the following
697 syntaxes may be used:
</p></div>
698 <div class=
"ilist"><ul>
706 file:///path/to/repo.git/
710 <div class=
"para"><p>These two syntaxes are mostly equivalent, except when cloning, when
711 the former implies --local option. See
<a href=
"git-clone.html">git-clone(
1)
</a> for
713 <div class=
"para"><p>When git doesn't know how to handle a certain transport protocol, it
714 attempts to use the
<em>remote-
<transport
></em> remote helper, if one
715 exists. To explicitly request a remote helper, the following syntax
716 may be used:
</p></div>
717 <div class=
"ilist"><ul>
720 <transport
>::
<address
>
724 <div class=
"para"><p>where
<address
> may be a path, a server and path, or an arbitrary
725 URL-like string recognized by the specific remote helper being
726 invoked. See
<a href=
"git-remote-helpers.html">git-remote-helpers(
1)
</a> for details.
</p></div>
727 <div class=
"para"><p>If there are a large number of similarly-named remote repositories and
728 you want to use a different format for them (such that the URLs you
729 use will be rewritten into URLs that work), you can create a
730 configuration section of the form:
</p></div>
731 <div class=
"listingblock">
732 <div class=
"content">
733 <pre><tt> [url
"<actual url base>"]
734 insteadOf =
<other url base
></tt></pre>
736 <div class=
"para"><p>For example, with this:
</p></div>
737 <div class=
"listingblock">
738 <div class=
"content">
739 <pre><tt> [url
"git://git.host.xz/"]
740 insteadOf = host.xz:/path/to/
741 insteadOf = work:
</tt></pre>
743 <div class=
"para"><p>a URL like
"work:repo.git" or like
"host.xz:/path/to/repo.git" will be
744 rewritten in any context that takes a URL to be
"git://git.host.xz/repo.git".
</p></div>
745 <div class=
"para"><p>If you want to rewrite URLs for push only, you can create a
746 configuration section of the form:
</p></div>
747 <div class=
"listingblock">
748 <div class=
"content">
749 <pre><tt> [url
"<actual url base>"]
750 pushInsteadOf =
<other url base
></tt></pre>
752 <div class=
"para"><p>For example, with this:
</p></div>
753 <div class=
"listingblock">
754 <div class=
"content">
755 <pre><tt> [url
"ssh://example.org/"]
756 pushInsteadOf = git://example.org/
</tt></pre>
758 <div class=
"para"><p>a URL like
"git://example.org/path/to/repo.git" will be rewritten to
759 "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
760 use the original URL.
</p></div>
762 <h2 id=
"_remotes_a_id_remotes_a">REMOTES
<a id=
"REMOTES"></a></h2>
763 <div class=
"sectionbody">
764 <div class=
"para"><p>The name of one of the following can be used instead
765 of a URL as
<tt><repository
></tt> argument:
</p></div>
766 <div class=
"ilist"><ul>
769 a remote in the git configuration file:
<tt>$GIT_DIR/config
</tt>,
774 a file in the
<tt>$GIT_DIR/remotes
</tt> directory, or
779 a file in the
<tt>$GIT_DIR/branches
</tt> directory.
783 <div class=
"para"><p>All of these also allow you to omit the refspec from the command line
784 because they each contain a refspec which git will use by default.
</p></div>
785 <h3 id=
"_named_remote_in_configuration_file">Named remote in configuration file
</h3><div style=
"clear:left"></div>
786 <div class=
"para"><p>You can choose to provide the name of a remote which you had previously
787 configured using
<a href=
"git-remote.html">git-remote(
1)
</a>,
<a href=
"git-config.html">git-config(
1)
</a>
788 or even by a manual edit to the
<tt>$GIT_DIR/config
</tt> file. The URL of
789 this remote will be used to access the repository. The refspec
790 of this remote will be used by default when you do
791 not provide a refspec on the command line. The entry in the
792 config file would appear like this:
</p></div>
793 <div class=
"listingblock">
794 <div class=
"content">
795 <pre><tt> [remote
"<name>"]
797 pushurl =
<pushurl
>
798 push =
<refspec
>
799 fetch =
<refspec
></tt></pre>
801 <div class=
"para"><p>The
<tt><pushurl
></tt> is used for pushes only. It is optional and defaults
802 to
<tt><url
></tt>.
</p></div>
803 <h3 id=
"_named_file_in_tt_git_dir_remotes_tt">Named file in
<tt>$GIT_DIR/remotes
</tt></h3><div style=
"clear:left"></div>
804 <div class=
"para"><p>You can choose to provide the name of a
805 file in
<tt>$GIT_DIR/remotes
</tt>. The URL
806 in this file will be used to access the repository. The refspec
807 in this file will be used as default when you do not
808 provide a refspec on the command line. This file should have the
809 following format:
</p></div>
810 <div class=
"listingblock">
811 <div class=
"content">
812 <pre><tt> URL: one of the above URL format
813 Push:
<refspec
>
814 Pull:
<refspec
>
817 <div class=
"para"><p><tt>Push:
</tt> lines are used by
<em>git push
</em> and
818 <tt>Pull:
</tt> lines are used by
<em>git pull
</em> and
<em>git fetch
</em>.
819 Multiple
<tt>Push:
</tt> and
<tt>Pull:
</tt> lines may
820 be specified for additional branch mappings.
</p></div>
821 <h3 id=
"_named_file_in_tt_git_dir_branches_tt">Named file in
<tt>$GIT_DIR/branches
</tt></h3><div style=
"clear:left"></div>
822 <div class=
"para"><p>You can choose to provide the name of a
823 file in
<tt>$GIT_DIR/branches
</tt>.
824 The URL in this file will be used to access the repository.
825 This file should have the following format:
</p></div>
826 <div class=
"listingblock">
827 <div class=
"content">
828 <pre><tt> <url
>#
<head
></tt></pre>
830 <div class=
"para"><p><tt><url
></tt> is required;
<tt>#
<head
></tt> is optional.
</p></div>
831 <div class=
"para"><p>Depending on the operation, git will use one of the following
832 refspecs, if you don't provide one on the command line.
833 <tt><branch
></tt> is the name of this file in
<tt>$GIT_DIR/branches
</tt> and
834 <tt><head
></tt> defaults to
<tt>master
</tt>.
</p></div>
835 <div class=
"para"><p>git fetch uses:
</p></div>
836 <div class=
"listingblock">
837 <div class=
"content">
838 <pre><tt> refs/heads/
<head
>:refs/heads/
<branch
></tt></pre>
840 <div class=
"para"><p>git push uses:
</p></div>
841 <div class=
"listingblock">
842 <div class=
"content">
843 <pre><tt> HEAD:refs/heads/
<head
></tt></pre>
846 <h2 id=
"_examples">EXAMPLES
</h2>
847 <div class=
"sectionbody">
848 <div class=
"ilist"><ul>
851 Update the remote-tracking branches:
853 <div class=
"listingblock">
854 <div class=
"content">
855 <pre><tt>$ git fetch origin
</tt></pre>
857 <div class=
"para"><p>The above command copies all branches from the remote refs/heads/
858 namespace and stores them to the local refs/remotes/origin/ namespace,
859 unless the branch.
<name
>.fetch option is used to specify a non-default
864 Using refspecs explicitly:
866 <div class=
"listingblock">
867 <div class=
"content">
868 <pre><tt>$ git fetch origin +pu:pu maint:tmp
</tt></pre>
870 <div class=
"para"><p>This updates (or creates, as necessary) branches
<tt>pu
</tt> and
<tt>tmp
</tt> in
871 the local repository by fetching from the branches (respectively)
872 <tt>pu
</tt> and
<tt>maint
</tt> from the remote repository.
</p></div>
873 <div class=
"para"><p>The
<tt>pu
</tt> branch will be updated even if it is does not fast-forward,
874 because it is prefixed with a plus sign;
<tt>tmp
</tt> will not be.
</p></div>
878 <h2 id=
"_see_also">SEE ALSO
</h2>
879 <div class=
"sectionbody">
880 <div class=
"para"><p><a href=
"git-pull.html">git-pull(
1)
</a></p></div>
882 <h2 id=
"_author">Author
</h2>
883 <div class=
"sectionbody">
884 <div class=
"para"><p>Written by Linus Torvalds
<torvalds@osdl.org
> and
885 Junio C Hamano
<gitster@pobox.com
></p></div>
887 <h2 id=
"_documentation">Documentation
</h2>
888 <div class=
"sectionbody">
889 <div class=
"para"><p>Documentation by David Greaves, Junio C Hamano and the git-list
<git@vger.kernel.org
>.
</p></div>
891 <h2 id=
"_git">GIT
</h2>
892 <div class=
"sectionbody">
893 <div class=
"para"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
896 <div id=
"footer-text">
897 Last updated
2010-
04-
24 02:
55:
54 UTC