3d0ed9af621a7f25ce69a2f97eed39cce6dd0b65
[git.git] / man1 / git-fetch.1
1 .\"Generated by db2man.xsl. Don't modify this, modify the source.
2 .de Sh \" Subsection
3 .br
4 .if t .Sp
5 .ne 5
6 .PP
7 \fB\\$1\fR
8 .PP
9 ..
10 .de Sp \" Vertical space (when we can't use .PP)
11 .if t .sp .5v
12 .if n .sp
13 ..
14 .de Ip \" List item
15 .br
16 .ie \\n(.$>=3 .ne \\$3
17 .el .ne 3
18 .IP "\\$1" \\$2
19 ..
20 .TH "GIT-FETCH" 1 "" "" ""
21 .SH NAME
22 git-fetch \- Download objects and a head from another repository.
23 .SH "SYNOPSIS"
24
25
26 git\-fetch <options> <repository> <refspec>...
27
28 .SH "DESCRIPTION"
29
30
31 Fetches named heads or tags from another repository, along with the objects necessary to complete them\&.
32
33
34 The ref names and their object names of fetched refs are stored in \&.git/FETCH_HEAD\&. This information is left for a later merge operation done by "git merge"\&.
35
36 .SH "OPTIONS"
37
38 .TP
39 \-a, \-\-append
40 Append ref names and object names of fetched refs to the existing contents of \&.git/FETCH_HEAD\&. Without this option old data in \&.git/FETCH_HEAD will be overwritten\&.
41
42 .TP
43 \-f, \-\-force
44 When git\-fetch is used with <rbranch>:<lbranch> refspec, it refuses to update the local branch <lbranch> unless the remote branch <rbranch> it fetches is a descendant of <lbranch>\&. This option overrides that check\&.
45
46 .TP
47 \-\-no\-tags
48 By default, git\-fetch fetches tags that point at objects that are downloaded from the remote repository and stores them locally\&. This option disables this automatic tag following\&.
49
50 .TP
51 \-t, \-\-tags
52 Most of the tags are fetched automatically as branch heads are downloaded, but tags that do not point at objects reachable from the branch heads that are being tracked will not be fetched by this mechanism\&. This flag lets all tags and their associated objects be downloaded\&.
53
54 .TP
55 \-u, \-\-update\-head\-ok
56 By default git\-fetch refuses to update the head which corresponds to the current branch\&. This flag disables the check\&. Note that fetching into the current branch will not update the index and working directory, so use it with care\&.
57
58 .TP
59 <repository>
60 The "remote" repository that is the source of a fetch or pull operation, or the destination of a push operation\&. One of the following notations can be used to name the remote repository:
61
62
63 .IP
64
65 .RS
66 .TP 3
67 \(bu
68 rsync://host\&.xz/path/to/repo\&.git/
69 .TP
70 \(bu
71 http://host\&.xz/path/to/repo\&.git/
72 .TP
73 \(bu
74 https://host\&.xz/path/to/repo\&.git/
75 .TP
76 \(bu
77 git://host\&.xz/path/to/repo\&.git/
78 .TP
79 \(bu
80 git://host\&.xz/~user/path/to/repo\&.git/
81 .TP
82 \(bu
83 ssh://host\&.xz/path/to/repo\&.git/
84 .TP
85 \(bu
86 ssh://host\&.xz/~user/path/to/repo\&.git/
87 .TP
88 \(bu
89 ssh://host\&.xz/~/path/to/repo\&.git
90 .LP
91 .RE
92 .IP
93 SSH Is the default transport protocol and also supports an scp\-like syntax\&. Both syntaxes support username expansion, as does the native git protocol\&. The following three are identical to the last three above, respectively:
94
95
96 .IP
97
98 .RS
99 .TP 3
100 \(bu
101 host\&.xz:/path/to/repo\&.git/
102 .TP
103 \(bu
104 host\&.xz:~user/path/to/repo\&.git/
105 .TP
106 \(bu
107 host\&.xz:path/to/repo\&.git
108 .LP
109 .RE
110 .IP
111 To sync with a local directory, use:
112
113
114 .IP
115
116 .RS
117 .TP 3
118 \(bu
119 /path/to/repo\&.git/
120 .LP
121 .RE
122 .IP
123 In addition to the above, as a short\-hand, the name of a file in $GIT_DIR/remotes directory can be given; the named file should be in the following format:
124
125
126 .nf
127 URL: one of the above URL format
128 Push: <refspec>
129 Pull: <refspec>
130 .fi
131 When such a short\-hand is specified in place of <repository> without <refspec> parameters on the command line, <refspec> specified on Push: lines or Pull: lines are used for git\-push and git\-fetch/git\-pull, respectively\&. Multiple Push: and and Pull: lines may be specified for additional branch mappings\&.
132
133 The name of a file in $GIT_DIR/branches directory can be specified as an older notation short\-hand; the named file should contain a single line, a URL in one of the above formats, optionally followed by a hash # and the name of remote head (URL fragment notation)\&. $GIT_DIR/branches/<remote> file that stores a <url> without the fragment is equivalent to have this in the corresponding file in the $GIT_DIR/remotes/ directory\&.
134
135
136 .nf
137 URL: <url>
138 Pull: refs/heads/master:<remote>
139 .fi
140 while having <url>#<head> is equivalent to
141
142 .nf
143 URL: <url>
144 Pull: refs/heads/<head>:<remote>
145 .fi
146
147 .TP
148 <refspec>
149 The canonical format of a <refspec> parameter is +?<src>:<dst>; that is, an optional plus +, followed by the source ref, followed by a colon :, followed by the destination ref\&.
150
151 When used in git\-push, the <src> side can be an arbitrary "SHA1 expression" that can be used as an argument to git\-cat\-file \-t\&. E\&.g\&. master~4 (push four parents before the current master head)\&.
152
153 For git\-push, the local ref that matches <src> is used to fast forward the remote ref that matches <dst>\&. If the optional plus + is used, the remote ref is updated even if it does not result in a fast forward update\&.
154
155 For git\-fetch and git\-pull, the remote ref that matches <src> is fetched, and if <dst> is not empty string, the local ref that matches it is fast forwarded using <src>\&. Again, if the optional plus + is used, the local ref is updated even if it does not result in a fast forward update\&.
156
157
158 .RS
159 .Sh "Note"
160 If the remote branch from which you want to pull is modified in non\-linear ways such as being rewound and rebased frequently, then a pull will attempt a merge with an older version of itself, likely conflict, and fail\&. It is under these conditions that you would want to use the + sign to indicate non\-fast\-forward updates will be needed\&. There is currently no easy way to determine or declare that a branch will be made available in a repository with this behavior; the pulling user simply must know this is the expected usage pattern for a branch\&.
161
162 .RE
163
164 .RS
165 .Sh "Note"
166 You never do your own development on branches that appear on the right hand side of a <refspec> colon on Pull: lines; they are to be updated by git\-fetch\&. If you intend to do development derived from a remote branch B, have a Pull: line to track it (i\&.e\&. Pull: B:remote\-B), and have a separate branch my\-B to do your development on top of it\&. The latter is created by git branch my\-B remote\-B (or its equivalent git checkout \-b my\-B remote\-B)\&. Run git fetch to keep track of the progress of the remote side, and when you see something new on the remote branch, merge it into your development branch with git pull \&. remote\-B, while you are on my\-B branch\&. The common Pull: master:origin mapping of a remote master branch to a local origin branch, which is then merged to a local development branch, again typically named master, is made when you run git clone for you to follow this pattern\&.
167
168 .RE
169
170 .RS
171 .Sh "Note"
172 There is a difference between listing multiple <refspec> directly on git\-pull command line and having multiple Pull: <refspec> lines for a <repository> and running git\-pull command without any explicit <refspec> parameters\&. <refspec> listed explicitly on the command line are always merged into the current branch after fetching\&. In other words, if you list more than one remote refs, you would be making an Octopus\&. While git\-pull run without any explicit <refspec> parameter takes default <refspec>s from Pull: lines, it merges only the first <refspec> found into the current branch, after fetching all the remote refs\&. This is because making an Octopus from remote refs is rarely done, while keeping track of multiple remote heads in one\-go by fetching more than one is often useful\&.
173
174 .RE
175 Some short\-cut notations are also supported\&.
176
177 .RS
178 .TP 3
179 \(bu
180 For backward compatibility, tag is almost ignored; it just makes the following parameter <tag> to mean a refspec refs/tags/<tag>:refs/tags/<tag>\&.
181 .TP
182 \(bu
183 A parameter <ref> without a colon is equivalent to <ref>: when pulling/fetching, and <ref>:<ref> when pushing\&. That is, do not store it locally if fetching, and update the same name if pushing\&.
184 .LP
185 .RE
186 .IP
187
188 .SH "SEE ALSO"
189
190
191 \fBgit\-pull\fR(1)
192
193 .SH "AUTHOR"
194
195
196 Written by Linus Torvalds <torvalds@osdl\&.org> and Junio C Hamano <junkio@cox\&.net>
197
198 .SH "DOCUMENTATION"
199
200
201 Documentation by David Greaves, Junio C Hamano and the git\-list <git@vger\&.kernel\&.org>\&.
202
203 .SH "GIT"
204
205
206 Part of the \fBgit\fR(7) suite
207