Autogenerated man pages for v1.1.2-g9e9b
[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 \-k, \-\-keep
56 Keep downloaded pack\&.
57
58 .TP
59 \-u, \-\-update\-head\-ok
60 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\&.
61
62 .TP
63 <repository>
64 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:
65
66
67 .IP
68
69 .RS
70 .TP 3
71 \(bu
72 rsync://host\&.xz/path/to/repo\&.git/
73 .TP
74 \(bu
75 http://host\&.xz/path/to/repo\&.git/
76 .TP
77 \(bu
78 https://host\&.xz/path/to/repo\&.git/
79 .TP
80 \(bu
81 git://host\&.xz/path/to/repo\&.git/
82 .TP
83 \(bu
84 git://host\&.xz/~user/path/to/repo\&.git/
85 .TP
86 \(bu
87 ssh://host\&.xz/path/to/repo\&.git/
88 .TP
89 \(bu
90 ssh://host\&.xz/~user/path/to/repo\&.git/
91 .TP
92 \(bu
93 ssh://host\&.xz/~/path/to/repo\&.git
94 .LP
95 .RE
96 .IP
97 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:
98
99
100 .IP
101
102 .RS
103 .TP 3
104 \(bu
105 host\&.xz:/path/to/repo\&.git/
106 .TP
107 \(bu
108 host\&.xz:~user/path/to/repo\&.git/
109 .TP
110 \(bu
111 host\&.xz:path/to/repo\&.git
112 .LP
113 .RE
114 .IP
115 To sync with a local directory, use:
116
117
118 .IP
119
120 .RS
121 .TP 3
122 \(bu
123 /path/to/repo\&.git/
124 .LP
125 .RE
126 .IP
127 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:
128
129
130 .nf
131 URL: one of the above URL format
132 Push: <refspec>
133 Pull: <refspec>
134 .fi
135 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\&.
136
137 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\&.
138
139
140 .nf
141 URL: <url>
142 Pull: refs/heads/master:<remote>
143 .fi
144 while having <url>#<head> is equivalent to
145
146 .nf
147 URL: <url>
148 Pull: refs/heads/<head>:<remote>
149 .fi
150
151 .TP
152 <refspec>
153 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\&.
154
155 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)\&.
156
157 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\&.
158
159 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\&.
160
161
162 .RS
163 .Sh "Note"
164 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\&.
165
166 .RE
167
168 .RS
169 .Sh "Note"
170 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\&.
171
172 .RE
173
174 .RS
175 .Sh "Note"
176 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\&.
177
178 .RE
179 Some short\-cut notations are also supported\&.
180
181 .RS
182 .TP 3
183 \(bu
184  tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>; used with pull or fetch, it requests fetching everything up to the given tag\&.
185 .TP
186 \(bu
187 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\&.
188 .LP
189 .RE
190 .IP
191
192 .SH "SEE ALSO"
193
194
195 \fBgit\-pull\fR(1)
196
197 .SH "AUTHOR"
198
199
200 Written by Linus Torvalds <torvalds@osdl\&.org> and Junio C Hamano <junkio@cox\&.net>
201
202 .SH "DOCUMENTATION"
203
204
205 Documentation by David Greaves, Junio C Hamano and the git\-list <git@vger\&.kernel\&.org>\&.
206
207 .SH "GIT"
208
209
210 Part of the \fBgit\fR(7) suite
211