1page.title=Repo command reference
2@jd:body
3
4<!--
5    Copyright 2013 The Android Open Source Project
6
7    Licensed under the Apache License, Version 2.0 (the "License");
8    you may not use this file except in compliance with the License.
9    You may obtain a copy of the License at
10
11        http://www.apache.org/licenses/LICENSE-2.0
12
13    Unless required by applicable law or agreed to in writing, software
14    distributed under the License is distributed on an "AS IS" BASIS,
15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16    See the License for the specific language governing permissions and
17    limitations under the License.
18-->
19
20<div id="qv-wrapper">
21  <div id="qv">
22    <h2>In this document</h2>
23    <ol id="auto-toc">
24    </ol>
25  </div>
26</div>
27<p>Repo usage takes the following form: </p>
28<pre><code>repo COMMAND OPTIONS
29</code></pre>
30<p>Optional elements are shown in brackets [ ]. Once Repo is installed, you can get information about any command by running   </p>
31<pre><code>repo help COMMAND
32</code></pre>
33<p>Many commands take a project list as an argument. You can specify project-list as a list of names or a list of paths to local source directories for the projects:</p>
34<pre><code>repo sync [PROJECT0 PROJECT1 ... PROJECTN]
35repo sync [/PATH/TO/PROJECT0 ... /PATH/TO/PROJECTN]
36</code></pre>
37
38<h2 id="init">init</h2>
39<pre><code>$ repo init -u URL [OPTIONS]
40</code></pre>
41<p>Installs Repo in the current directory. This creates a <code>.repo/</code> directory that contains Git repositories for the Repo source code and the standard Android manifest files. The <code>.repo/</code> directory also contains <code>manifest.xml</code>, which is a symlink to the selected manifest in the <code>.repo/manifests/</code> directory.</p>
42<p>Options:</p>
43<ul>
44<li>
45<p><code>-u</code>: specify a URL from which to retrieve a manifest repository. The common manifest can be found at <code>https://android.googlesource.com/platform/manifest</code></p>
46</li>
47<li>
48<p><code>-m</code>: select a manifest file within the repository. If no manifest name is selected, the default is default.xml. </p>
49</li>
50<li>
51<p><code>-b</code>: specify a revision, i.e., a particular manifest-branch.</p>
52</li>
53</ul>
54<p><em>Note: For all remaining Repo commands, the current working directory must either be the parent directory of <code>.repo/</code> or a subdirectory of the parent directory.</em></p>
55<h2 id="sync">sync</h2>
56<pre><code>repo sync [PROJECT_LIST]
57</code></pre>
58<p>Downloads new changes and updates the working files in your local environment. If you run <code>repo sync</code> without any arguments, it will synchronize the files for all the projects.</p>
59<p>When you run <code>repo sync</code>, this is what happens:</p>
60<ul>
61<li>
62<p>If the project has never been synchronized, then <code>repo sync</code> is equivalent to <code>git clone</code>. All branches in the remote repository are copied to the local project directory.</p>
63</li>
64<li>
65<p>If the project has already been synchronized once, then <code>repo sync</code> is equivalent to:</p>
66<pre><code>git remote update
67git rebase origin/BRANCH
68</code></pre>
69<p>where <code>BRANCH</code> is the currently checked-out branch in the local project directory. If the local branch is not tracking a branch in the remote repository, then no synchronization will occur for the project.</p>
70</li>
71<li>
72<p>If the git rebase operation results in merge conflicts, you will need to use the normal Git commands (for example, <code>git rebase --continue</code>) to resolve the conflicts.</p>
73</li>
74</ul>
75<p>After a successful <code>repo sync</code>, the code in specified projects will be up to date with the code in the remote repository.</p>
76<p>Options:</p>
77<ul>
78<li>
79<p><code>-d</code>: switch specified projects back to the manifest revision.  Helpful if the project is currently on a topic branch, but the manifest revision is temporarily needed.</p>
80</li>
81<li>
82<p><code>-s</code>: sync to a known good build as specified by the manifest-server element in the current manifest.</p>
83</li>
84<li>
85<p><code>-f</code>: proceed with syncing other projects even if a project fails to sync.</p>
86</li>
87</ul>
88<h2 id="upload">upload</h2>
89<pre><code>repo upload [PROJECT_LIST]
90</code></pre>
91<p>For the specified projects, Repo compares the local branches to the remote branches updated during the last repo sync. Repo will prompt you to select one or more of the branches that have not yet been uploaded for review.</p>
92<p>After you select one or more branches, all commits on the selected branches
93are transmitted to Gerrit over an HTTPS connection. You will need to
94configure an HTTPS password to enable upload authorization. Visit the
95<a href="https://android-review.googlesource.com/new-password">Password Generator</a>
96to generate a new username/password pair to use over HTTPS.</p>
97<p>When Gerrit receives the object data over its server, it will turn each
98commit into a change so that reviewers can comment on each commit
99individually. To combine several "checkpoint" commits together into a
100single commit, use git rebase -i before you run repo upload.</p>
101<p>If you run repo upload without any arguments, it will search all the projects for changes to upload.</p>
102<p>To make edits to changes after they have been uploaded, you should use a tool like <code>git rebase -i</code> or <code>git commit --amend</code> to update your local commits.  After your edits are complete:</p>
103<ul>
104<li>
105<p>Make sure the updated branch is the currently checked out branch.</p>
106</li>
107<li>
108<p>Use <code>repo upload --replace PROJECT</code> to open the change matching editor.</p>
109</li>
110<li>
111<p>For each commit in the series, enter the Gerrit change ID inside the brackets:</p>
112<pre><code># Replacing from branch foo
113[ 3021 ] 35f2596c Refactor part of GetUploadableBranches to lookup one specific...
114[ 2829 ] ec18b4ba Update proto client to support patch set replacments
115[ 3022 ] c99883fe Teach 'repo upload --replace' how to add replacement patch se...
116# Insert change numbers in the brackets to add a new patch set.
117# To create a new change record, leave the brackets empty.
118</code></pre>
119</li>
120</ul>
121<p>After the upload is complete the changes will have an additional Patch Set.</p>
122<h2 id="diff">diff</h2>
123<pre><code>repo diff [PROJECT_LIST]
124</code></pre>
125<p>Shows outstanding changes between commit and working tree using <code>git diff</code>. </p>
126<h2 id="download">download</h2>
127<pre><code>repo download TARGET CHANGE
128</code></pre>
129<p>Downloads the specified change from the review system and makes it available in your project's local working directory.</p>
130<p>For example, to download <a href="https://android-review.googlesource.com/23823">change 23823</a> into your platform/frameworks/base directory:</p>
131<pre><code>$ repo download platform/build 23823
132</code></pre>
133<p>A <code>repo sync</code> should effectively remove any commits retrieved via <code>repo download</code>. Or, you can check out the remote branch; e.g., <code>git checkout m/master</code>.</p>
134<p>*Note: There is a slight mirroring lag between when a change is visible on
135the web in <a href="https://android-review.googlesource.com/">Gerrit</a> and when
136<code>repo download</code> will be able to find it for all users, because of replication
137delays to all servers worldwide.</p>
138<h2 id="forall">forall</h2>
139<pre><code>repo forall [PROJECT_LIST] -c COMMAND
140</code></pre>
141<p>Executes the given shell command in each project.  The following additional environment variables are made available by <code>repo forall</code>:</p>
142<ul>
143<li>
144<p><code>REPO_PROJECT</code> is set to the unique name of the project.</p>
145</li>
146<li>
147<p><code>REPO_PATH</code> is the path relative to the root of the client.</p>
148</li>
149<li>
150<p><code>REPO_REMOTE</code> is the name of the remote system from the manifest.</p>
151</li>
152<li>
153<p><code>REPO_LREV</code> is the name of the revision from the manifest, translated to a local tracking branch.  Used if you need to pass the manifest revision to a locally executed git command.</p>
154</li>
155<li>
156<p><code>REPO_RREV</code> is the name of the revision from the manifest, exactly as written in the manifest.</p>
157</li>
158</ul>
159<p>Options:</p>
160<ul>
161<li>
162<p><code>-c</code>: command and arguments to execute. The command is evaluated through <code>/bin/sh</code> and any arguments after it are passed through as shell positional parameters.</p>
163</li>
164<li>
165<p><code>-p</code>: show project headers before output of the specified command.  This is achieved by binding pipes to the command's stdin, stdout, and sterr streams, and piping all output into a continuous stream that is displayed in a single pager session.</p>
166</li>
167<li>
168<p><code>-v</code>: show messages the command writes to stderr.  </p>
169</li>
170</ul>
171<h2 id="prune">prune</h2>
172<pre><code>repo prune [PROJECT_LIST]
173</code></pre>
174<p>Prunes (deletes) topics that are already merged.</p>
175<h2 id="start">start</h2>
176<pre><code>repo start BRANCH_NAME [PROJECT_LIST]
177</code></pre>
178<p>Begins a new branch for development, starting from the revision specified in the manifest.</p>
179<p>The <code>BRANCH_NAME</code> argument should provide a short description of the change you are trying to make to the projects.If you don't know, consider using the name default.</p>
180<p>The <code>PROJECT_LIST</code> specifies which projects will participate in this topic branch. </p>
181<p><em>Note: "." is a useful shorthand for the project in the current working directory.</em></p>
182<h2 id="status">status</h2>
183<pre><code>repo status [PROJECT_LIST]
184</code></pre>
185<p>Compares the working tree to the staging area (index) and the most recent commit on this branch (HEAD) in each project specified.  Displays a summary line for each file where there is a difference between these three states.</p>
186<p>To see the status for only the current branch, run <code>repo status</code>. The status information will be listed by project. For each file in the project, a two-letter code is used:</p>
187<p>In the first column, an uppercase letter indicates how the staging area differs from the last committed state.</p>
188<table>
189<thead>
190<tr>
191<th>letter</th>
192<th>meaning</th>
193<th>description</th>
194</tr>
195</thead>
196<tbody>
197<tr>
198<td>-</td>
199<td>no change</td>
200<td>same in HEAD and index</td>
201</tr>
202<tr>
203<td>A</td>
204<td>added</td>
205<td>not in HEAD, in index</td>
206</tr>
207<tr>
208<td>M</td>
209<td>modified</td>
210<td>in HEAD, modified in index</td>
211</tr>
212<tr>
213<td>D</td>
214<td>deleted</td>
215<td>in HEAD, not in index</td>
216</tr>
217<tr>
218<td>R</td>
219<td>renamed</td>
220<td>not in HEAD, path changed in index</td>
221</tr>
222<tr>
223<td>C</td>
224<td>copied</td>
225<td>not in HEAD, copied from another in index</td>
226</tr>
227<tr>
228<td>T</td>
229<td>mode changed</td>
230<td>same content in HEAD and index, mode changed</td>
231</tr>
232<tr>
233<td>U</td>
234<td>unmerged</td>
235<td>conflict between HEAD and index; resolution required</td>
236</tr>
237</tbody>
238</table>
239<p>In the second column, a lowercase letter indicates how the working directory differs from the index.</p>
240<table>
241<thead>
242<tr>
243<th>letter</th>
244<th>meaning</th>
245<th>description</th>
246</tr>
247</thead>
248<tbody>
249<tr>
250<td>-</td>
251<td>new/unknown</td>
252<td>not in index, in work tree</td>
253</tr>
254<tr>
255<td>m</td>
256<td>modified</td>
257<td>in index, in work tree, modified</td>
258</tr>
259<tr>
260<td>d</td>
261<td>deleted</td>
262<td>in index, not in work tree</td>
263</tr>
264</tbody>
265</table>
266