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.4.5" />
7 <title>git-fetch(
1)
</title>
8 <style type=
"text/css">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.5em;
116 margin-bottom: 1.5em;
118 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
119 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
120 div
.admonitionblock
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.5em;
129 div
.content
{ /* Block element content. */
133 /* Block element titles. */
134 div
.title
, caption
.title
{
136 font-family: sans-serif
;
140 margin-bottom: 0.5em;
146 td div
.title:first-child
{
149 div
.content div
.title:first-child
{
152 div
.content
+ div
.title
{
156 div
.sidebarblock
> div
.content
{
158 border: 1px solid silver
;
162 div
.listingblock
> div
.content
{
163 border: 1px solid silver
;
172 div
.quoteblock
> div
.attribution
{
181 div
.verseblock
> div
.content
{
184 div
.verseblock
> div
.attribution
{
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div
.verseblock
+ div
.attribution
{
193 div
.admonitionblock
.icon
{
197 text-decoration: underline
;
199 padding-right: 0.5em;
201 div
.admonitionblock td
.content
{
203 border-left: 2px solid silver
;
206 div
.exampleblock
> div
.content
{
207 border-left: 2px solid silver
;
211 div
.imageblock div
.content
{ padding-left: 0; }
212 span
.image img
{ border-style: none
; }
213 a
.image:visited
{ color: white
; }
217 margin-bottom: 0.8em;
230 list-style-position: outside
;
233 list-style-type: decimal
;
236 list-style-type: lower-alpha
;
239 list-style-type: upper-alpha
;
242 list-style-type: lower-roman
;
245 list-style-type: upper-roman
;
248 div
.compact ul
, div
.compact ol
,
249 div
.compact p
, div
.compact p
,
250 div
.compact div
, div
.compact div
{
252 margin-bottom: 0.1em;
255 div
.tableblock
> table
{
256 border: 3px solid
#527bbd;
259 font-family: sans-serif
;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div
.tableblock
> table
[frame
="void"] {
275 div
.tableblock
> table
[frame
="hsides"] {
276 border-left-style: none
;
277 border-right-style: none
;
279 div
.tableblock
> table
[frame
="vsides"] {
280 border-top-style: none
;
281 border-bottom-style: none
;
287 margin-bottom: 0.8em;
290 padding-bottom: 15px;
292 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
298 padding-right: 0.8em;
304 div
.hdlist
.compact tr
{
314 div#footer-badges
{ display: none
; }
319 font-family: sans-serif
;
323 margin-bottom: 0.1em;
326 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
342 /* Overrides for manpage documents */
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver
;
347 border-bottom: 2px solid silver
;
357 div#toc
{ display: none
; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div
.sidebar-content
{
364 border: 1px solid silver
;
367 div
.sidebar-title
, div
.image-title
{
369 font-family: sans-serif
;
372 margin-bottom: 0.5em;
375 div
.listingblock div
.content
{
376 border: 1px solid silver
;
381 div
.quoteblock-attribution
{
386 div
.verseblock-content
{
389 div
.verseblock-attribution
{
394 div
.exampleblock-content
{
395 border-left: 2px solid silver
;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc
a:visited
{ color: blue
; }
406 git-fetch(
1) Manual Page
409 <div class=
"sectionbody">
411 Download objects and refs from another repository
415 <h2 id=
"_synopsis">SYNOPSIS
</h2>
416 <div class=
"sectionbody">
417 <div class=
"paragraph"><p><em>git fetch
</em> [
<options
>] [
<repository
> [
<refspec
>…]]
</p></div>
418 <div class=
"paragraph"><p><em>git fetch
</em> [
<options
>]
<group
></p></div>
419 <div class=
"paragraph"><p><em>git fetch
</em> --multiple [
<options
>] [(
<repository
> |
<group
>)
…]
</p></div>
420 <div class=
"paragraph"><p><em>git fetch
</em> --all [
<options
>]
</p></div>
422 <h2 id=
"_description">DESCRIPTION
</h2>
423 <div class=
"sectionbody">
424 <div class=
"paragraph"><p>Fetches named heads or tags from one or more other repositories,
425 along with the objects necessary to complete them.
</p></div>
426 <div class=
"paragraph"><p>The ref names and their object names of fetched refs are stored
427 in
<tt>.git/FETCH_HEAD
</tt>. This information is left for a later merge
428 operation done by
<em>git merge
</em>.
</p></div>
429 <div class=
"paragraph"><p>When
<refspec
> stores the fetched result in remote-tracking branches,
430 the tags that point at these branches are automatically
431 followed. This is done by first fetching from the remote using
432 the given
<refspec
>s, and if the repository has objects that are
433 pointed by remote tags that it does not yet have, then fetch
434 those missing tags. If the other end has tags that point at
435 branches you are not interested in, you will not get them.
</p></div>
436 <div class=
"paragraph"><p><em>git fetch
</em> can fetch from either a single named repository, or
437 or from several repositories at once if
<group
> is given and
438 there is a remotes.
<group
> entry in the configuration file.
439 (See
<a href=
"git-config.html">git-config(
1)
</a>).
</p></div>
441 <h2 id=
"_options">OPTIONS
</h2>
442 <div class=
"sectionbody">
443 <div class=
"dlist"><dl>
460 Append ref names and object names of fetched refs to the
461 existing contents of
<tt>.git/FETCH_HEAD
</tt>. Without this
462 option old data in
<tt>.git/FETCH_HEAD
</tt> will be overwritten.
466 --depth=
<depth
>
470 Deepen the history of a
<em>shallow
</em> repository created by
471 <tt>git clone
</tt> with
<tt>--depth=
<depth
></tt> option (see
<a href=
"git-clone.html">git-clone(
1)
</a>)
472 by the specified number of commits.
480 Show what would be done, without making any changes.
491 When
<em>git fetch
</em> is used with
<tt><rbranch
>:
<lbranch
></tt>
492 refspec, it refuses to update the local branch
493 <tt><lbranch
></tt> unless the remote branch
<tt><rbranch
></tt> it
494 fetches is a descendant of
<tt><lbranch
></tt>. This option
495 overrides that check.
506 Keep downloaded pack.
514 Allow several
<repository
> and
<group
> arguments to be
515 specified. No
<refspec
>s may be specified.
526 After fetching, remove any remote-tracking branches which
527 no longer exist on the remote.
538 By default, tags that point at objects that are downloaded
539 from the remote repository are fetched and stored locally.
540 This option disables this automatic tag following. The default
541 behavior for a remote may be specified with the remote.
<name
>.tagopt
542 setting. See
<a href=
"git-config.html">git-config(
1)
</a>.
553 Most of the tags are fetched automatically as branch
554 heads are downloaded, but tags that do not point at
555 objects reachable from the branch heads that are being
556 tracked will not be fetched by this mechanism. This
557 flag lets all tags and their associated objects be
558 downloaded. The default behavior for a remote may be
559 specified with the remote.
<name
>.tagopt setting. See
560 <a href=
"git-config.html">git-config(
1)
</a>.
564 --[no-]recurse-submodules
568 This option controls if new commits of all populated submodules should
569 be fetched too (see
<a href=
"git-config.html">git-config(
1)
</a> and
<a href=
"gitmodules.html">gitmodules(
5)
</a>).
573 --submodule-prefix=
<path
>
577 Prepend
<path
> to paths printed in informative messages
578 such as
"Fetching submodule foo". This option is used
579 internally when recursing over submodules.
590 By default
<em>git fetch
</em> refuses to update the head which
591 corresponds to the current branch. This flag disables the
592 check. This is purely for the internal use for
<em>git pull
</em>
593 to communicate with
<em>git fetch
</em>, and unless you are
594 implementing your own Porcelain you are not supposed to
599 --upload-pack
<upload-pack
>
603 When given, and the repository to fetch from is handled
604 by
<em>git fetch-pack
</em>,
<em>--exec=
<upload-pack
></em> is passed to
605 the command to specify non-default path for the command
606 run on the other end.
617 Pass --quiet to git-fetch-pack and silence any other internally
618 used git commands. Progress is not reported to the standard error
638 Progress status is reported on the standard error stream
639 by default when it is attached to a terminal, unless -q
640 is specified. This flag forces progress status even if the
641 standard error stream is not directed to a terminal.
649 The
"remote" repository that is the source of a fetch
650 or pull operation. This parameter can be either a URL
651 (see the section
<a href=
"#URLS">GIT URLS
</a> below) or the name
652 of a remote (see the section
<a href=
"#REMOTES">REMOTES
</a> below).
660 A name referring to a list of repositories as the value
661 of remotes.
<group
> in the configuration file.
662 (See
<a href=
"git-config.html">git-config(
1)
</a>).
670 The format of a
<refspec
> parameter is an optional plus
671 <tt>+</tt>, followed by the source ref
<src
>, followed
672 by a colon
<tt>:
</tt>, followed by the destination ref
<dst
>.
674 <div class=
"paragraph"><p>The remote ref that matches
<src
>
675 is fetched, and if
<dst
> is not empty string, the local
676 ref that matches it is fast-forwarded using
<src
>.
677 If the optional plus
<tt>+
</tt> is used, the local ref
678 is updated even if it does not result in a fast-forward
680 <div class=
"admonitionblock">
683 <div class=
"title">Note
</div>
685 <td class=
"content">If the remote branch from which you want to pull is
686 modified in non-linear ways such as being rewound and
687 rebased frequently, then a pull will attempt a merge with
688 an older version of itself, likely conflict, and fail.
689 It is under these conditions that you would want to use
690 the
<tt>+
</tt> sign to indicate non-fast-forward updates will
691 be needed. There is currently no easy way to determine
692 or declare that a branch will be made available in a
693 repository with this behavior; the pulling user simply
694 must know this is the expected usage pattern for a branch.
</td>
697 <div class=
"admonitionblock">
700 <div class=
"title">Note
</div>
702 <td class=
"content">You never do your own development on branches that appear
703 on the right hand side of a
<refspec
> colon on
<tt>Pull:
</tt> lines;
704 they are to be updated by
<em>git fetch
</em>. If you intend to do
705 development derived from a remote branch
<tt>B
</tt>, have a
<tt>Pull:
</tt>
706 line to track it (i.e.
<tt>Pull: B:remote-B
</tt>), and have a separate
707 branch
<tt>my-B
</tt> to do your development on top of it. The latter
708 is created by
<tt>git branch my-B remote-B
</tt> (or its equivalent
<tt>git
709 checkout -b my-B remote-B
</tt>). Run
<tt>git fetch
</tt> to keep track of
710 the progress of the remote side, and when you see something new
711 on the remote branch, merge it into your development branch with
712 <tt>git pull . remote-B
</tt>, while you are on
<tt>my-B
</tt> branch.
</td>
715 <div class=
"admonitionblock">
718 <div class=
"title">Note
</div>
720 <td class=
"content">There is a difference between listing multiple
<refspec
>
721 directly on
<em>git pull
</em> command line and having multiple
722 <tt>Pull:
</tt> <refspec
> lines for a
<repository
> and running
723 <em>git pull
</em> command without any explicit
<refspec
> parameters.
724 <refspec
> listed explicitly on the command line are always
725 merged into the current branch after fetching. In other words,
726 if you list more than one remote refs, you would be making
727 an Octopus. While
<em>git pull
</em> run without any explicit
<refspec
>
728 parameter takes default
<refspec
>s from
<tt>Pull:
</tt> lines, it
729 merges only the first
<refspec
> found into the current branch,
730 after fetching all the remote refs. This is because making an
731 Octopus from remote refs is rarely done, while keeping track
732 of multiple remote heads in one-go by fetching more than one
733 is often useful.
</td>
736 <div class=
"paragraph"><p>Some short-cut notations are also supported.
</p></div>
737 <div class=
"ulist"><ul>
740 <tt>tag
<tag
></tt> means the same as
<tt>refs/tags/
<tag
>:refs/tags/
<tag
></tt>;
741 it requests fetching everything up to the given tag.
746 A parameter
<ref
> without a colon is equivalent to
747 <ref
>: when pulling/fetching, so it merges
<ref
> into the current
748 branch without storing the remote branch anywhere locally
755 <h2 id=
"_git_urls_a_id_urls_a">GIT URLS
<a id=
"URLS"></a></h2>
756 <div class=
"sectionbody">
757 <div class=
"paragraph"><p>In general, URLs contain information about the transport protocol, the
758 address of the remote server, and the path to the repository.
759 Depending on the transport protocol, some of this information may be
761 <div class=
"paragraph"><p>Git natively supports ssh, git, http, https, ftp, ftps, and rsync
762 protocols. The following syntaxes may be used with them:
</p></div>
763 <div class=
"ulist"><ul>
766 ssh://
[user@
]host.xz
[:port
]/path/to/repo.git/
771 git://host.xz
[:port
]/path/to/repo.git/
776 http
[s
]://host.xz
[:port
]/path/to/repo.git/
781 ftp
[s
]://host.xz
[:port
]/path/to/repo.git/
786 rsync://host.xz/path/to/repo.git/
790 <div class=
"paragraph"><p>An alternative scp-like syntax may also be used with the ssh protocol:
</p></div>
791 <div class=
"ulist"><ul>
794 [user@
]host.xz:path/to/repo.git/
798 <div class=
"paragraph"><p>The ssh and git protocols additionally support ~username expansion:
</p></div>
799 <div class=
"ulist"><ul>
802 ssh://
[user@
]host.xz
[:port
]/~
[user
]/path/to/repo.git/
807 git://host.xz
[:port
]/~
[user
]/path/to/repo.git/
812 [user@
]host.xz:/~
[user
]/path/to/repo.git/
816 <div class=
"paragraph"><p>For local repositories, also supported by git natively, the following
817 syntaxes may be used:
</p></div>
818 <div class=
"ulist"><ul>
826 <a href=
"file:///path/to/repo.git/">file:///path/to/repo.git/
</a>
830 <div class=
"paragraph"><p>These two syntaxes are mostly equivalent, except when cloning, when
831 the former implies --local option. See
<a href=
"git-clone.html">git-clone(
1)
</a> for
833 <div class=
"paragraph"><p>When git doesn
’t know how to handle a certain transport protocol, it
834 attempts to use the
<em>remote-
<transport
></em> remote helper, if one
835 exists. To explicitly request a remote helper, the following syntax
836 may be used:
</p></div>
837 <div class=
"ulist"><ul>
840 <transport
>::
<address
>
844 <div class=
"paragraph"><p>where
<address
> may be a path, a server and path, or an arbitrary
845 URL-like string recognized by the specific remote helper being
846 invoked. See
<a href=
"git-remote-helpers.html">git-remote-helpers(
1)
</a> for details.
</p></div>
847 <div class=
"paragraph"><p>If there are a large number of similarly-named remote repositories and
848 you want to use a different format for them (such that the URLs you
849 use will be rewritten into URLs that work), you can create a
850 configuration section of the form:
</p></div>
851 <div class=
"listingblock">
852 <div class=
"content">
853 <pre><tt> [url
"<actual url base>"]
854 insteadOf =
<other url base
></tt></pre>
856 <div class=
"paragraph"><p>For example, with this:
</p></div>
857 <div class=
"listingblock">
858 <div class=
"content">
859 <pre><tt> [url
"git://git.host.xz/"]
860 insteadOf = host.xz:/path/to/
861 insteadOf = work:
</tt></pre>
863 <div class=
"paragraph"><p>a URL like
"work:repo.git" or like
"host.xz:/path/to/repo.git" will be
864 rewritten in any context that takes a URL to be
"git://git.host.xz/repo.git".
</p></div>
865 <div class=
"paragraph"><p>If you want to rewrite URLs for push only, you can create a
866 configuration section of the form:
</p></div>
867 <div class=
"listingblock">
868 <div class=
"content">
869 <pre><tt> [url
"<actual url base>"]
870 pushInsteadOf =
<other url base
></tt></pre>
872 <div class=
"paragraph"><p>For example, with this:
</p></div>
873 <div class=
"listingblock">
874 <div class=
"content">
875 <pre><tt> [url
"ssh://example.org/"]
876 pushInsteadOf = git://example.org/
</tt></pre>
878 <div class=
"paragraph"><p>a URL like
"git://example.org/path/to/repo.git" will be rewritten to
879 "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
880 use the original URL.
</p></div>
882 <h2 id=
"_remotes_a_id_remotes_a">REMOTES
<a id=
"REMOTES"></a></h2>
883 <div class=
"sectionbody">
884 <div class=
"paragraph"><p>The name of one of the following can be used instead
885 of a URL as
<tt><repository
></tt> argument:
</p></div>
886 <div class=
"ulist"><ul>
889 a remote in the git configuration file:
<tt>$GIT_DIR/config
</tt>,
894 a file in the
<tt>$GIT_DIR/remotes
</tt> directory, or
899 a file in the
<tt>$GIT_DIR/branches
</tt> directory.
903 <div class=
"paragraph"><p>All of these also allow you to omit the refspec from the command line
904 because they each contain a refspec which git will use by default.
</p></div>
905 <h3 id=
"_named_remote_in_configuration_file">Named remote in configuration file
</h3><div style=
"clear:left"></div>
906 <div class=
"paragraph"><p>You can choose to provide the name of a remote which you had previously
907 configured using
<a href=
"git-remote.html">git-remote(
1)
</a>,
<a href=
"git-config.html">git-config(
1)
</a>
908 or even by a manual edit to the
<tt>$GIT_DIR/config
</tt> file. The URL of
909 this remote will be used to access the repository. The refspec
910 of this remote will be used by default when you do
911 not provide a refspec on the command line. The entry in the
912 config file would appear like this:
</p></div>
913 <div class=
"listingblock">
914 <div class=
"content">
915 <pre><tt> [remote
"<name>"]
917 pushurl =
<pushurl
>
918 push =
<refspec
>
919 fetch =
<refspec
></tt></pre>
921 <div class=
"paragraph"><p>The
<tt><pushurl
></tt> is used for pushes only. It is optional and defaults
922 to
<tt><url
></tt>.
</p></div>
923 <h3 id=
"_named_file_in_tt_git_dir_remotes_tt">Named file in
<tt>$GIT_DIR/remotes
</tt></h3><div style=
"clear:left"></div>
924 <div class=
"paragraph"><p>You can choose to provide the name of a
925 file in
<tt>$GIT_DIR/remotes
</tt>. The URL
926 in this file will be used to access the repository. The refspec
927 in this file will be used as default when you do not
928 provide a refspec on the command line. This file should have the
929 following format:
</p></div>
930 <div class=
"listingblock">
931 <div class=
"content">
932 <pre><tt> URL: one of the above URL format
933 Push:
<refspec
>
934 Pull:
<refspec
></tt></pre>
936 <div class=
"paragraph"><p><tt>Push:
</tt> lines are used by
<em>git push
</em> and
937 <tt>Pull:
</tt> lines are used by
<em>git pull
</em> and
<em>git fetch
</em>.
938 Multiple
<tt>Push:
</tt> and
<tt>Pull:
</tt> lines may
939 be specified for additional branch mappings.
</p></div>
940 <h3 id=
"_named_file_in_tt_git_dir_branches_tt">Named file in
<tt>$GIT_DIR/branches
</tt></h3><div style=
"clear:left"></div>
941 <div class=
"paragraph"><p>You can choose to provide the name of a
942 file in
<tt>$GIT_DIR/branches
</tt>.
943 The URL in this file will be used to access the repository.
944 This file should have the following format:
</p></div>
945 <div class=
"listingblock">
946 <div class=
"content">
947 <pre><tt> <url
>#
<head
></tt></pre>
949 <div class=
"paragraph"><p><tt><url
></tt> is required;
<tt>#
<head
></tt> is optional.
</p></div>
950 <div class=
"paragraph"><p>Depending on the operation, git will use one of the following
951 refspecs, if you don
’t provide one on the command line.
952 <tt><branch
></tt> is the name of this file in
<tt>$GIT_DIR/branches
</tt> and
953 <tt><head
></tt> defaults to
<tt>master
</tt>.
</p></div>
954 <div class=
"paragraph"><p>git fetch uses:
</p></div>
955 <div class=
"listingblock">
956 <div class=
"content">
957 <pre><tt> refs/heads/
<head
>:refs/heads/
<branch
></tt></pre>
959 <div class=
"paragraph"><p>git push uses:
</p></div>
960 <div class=
"listingblock">
961 <div class=
"content">
962 <pre><tt> HEAD:refs/heads/
<head
></tt></pre>
965 <h2 id=
"_examples">EXAMPLES
</h2>
966 <div class=
"sectionbody">
967 <div class=
"ulist"><ul>
970 Update the remote-tracking branches:
972 <div class=
"listingblock">
973 <div class=
"content">
974 <pre><tt>$ git fetch origin
</tt></pre>
976 <div class=
"paragraph"><p>The above command copies all branches from the remote refs/heads/
977 namespace and stores them to the local refs/remotes/origin/ namespace,
978 unless the branch.
<name
>.fetch option is used to specify a non-default
983 Using refspecs explicitly:
985 <div class=
"listingblock">
986 <div class=
"content">
987 <pre><tt>$ git fetch origin +pu:pu maint:tmp
</tt></pre>
989 <div class=
"paragraph"><p>This updates (or creates, as necessary) branches
<tt>pu
</tt> and
<tt>tmp
</tt> in
990 the local repository by fetching from the branches (respectively)
991 <tt>pu
</tt> and
<tt>maint
</tt> from the remote repository.
</p></div>
992 <div class=
"paragraph"><p>The
<tt>pu
</tt> branch will be updated even if it is does not fast-forward,
993 because it is prefixed with a plus sign;
<tt>tmp
</tt> will not be.
</p></div>
997 <h2 id=
"_see_also">SEE ALSO
</h2>
998 <div class=
"sectionbody">
999 <div class=
"paragraph"><p><a href=
"git-pull.html">git-pull(
1)
</a></p></div>
1001 <h2 id=
"_author">Author
</h2>
1002 <div class=
"sectionbody">
1003 <div class=
"paragraph"><p>Written by Linus Torvalds
<<a href=
"mailto:torvalds@osdl.org">torvalds@osdl.org
</a>> and
1004 Junio C Hamano
<<a href=
"mailto:gitster@pobox.com">gitster@pobox.com
</a>></p></div>
1006 <h2 id=
"_documentation">Documentation
</h2>
1007 <div class=
"sectionbody">
1008 <div class=
"paragraph"><p>Documentation by David Greaves, Junio C Hamano and the git-list
<<a href=
"mailto:git@vger.kernel.org">git@vger.kernel.org
</a>>.
</p></div>
1010 <h2 id=
"_git">GIT
</h2>
1011 <div class=
"sectionbody">
1012 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
1015 <div id=
"footer-text">
1016 Last updated
2010-
11-
25 03:
13:
41 UTC