Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: docs/man7/depot_tools_tutorial.7

Issue 225433003: Add a basic tutorial for the tools in depot_tools. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@git_map
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 '\" t
2 .\" Title: depot_tools_tutorial
3 .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
4 .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
5 .\" Date: 04/04/2014
6 .\" Manual: Chromium depot_tools Manual
7 .\" Source: depot_tools b4ee6b0
8 .\" Language: English
9 .\"
10 .TH "DEPOT_TOOLS_TUTORIAL" "7" "04/04/2014" "depot_tools b4ee6b0" "Chromium depo t_tools Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 depot_tools_tutorial \- A tutorial introduction to the Chromium depot_tools git extensions\&.
32 .SH "DESCRIPTION"
33 .sp
34 The Chromium \fBdepot_tools\fR(7) suite contains many git workflow\-enhancing to ols which are designed to work together to enable anyone to wrangle the Chromium codebase expertly\&. This tutorial explains how to do development on Chromium u sing these tools\&. This will cover:
35 .sp
36 .RS 4
37 .ie n \{\
38 \h'-04'\(bu\h'+03'\c
39 .\}
40 .el \{\
41 .sp -1
42 .IP \(bu 2.3
43 .\}
44 Setting up
45 .RE
46 .sp
47 .RS 4
48 .ie n \{\
49 \h'-04'\(bu\h'+03'\c
50 .\}
51 .el \{\
52 .sp -1
53 .IP \(bu 2.3
54 .\}
55 Getting the code
56 .RE
57 .sp
58 .RS 4
59 .ie n \{\
60 \h'-04'\(bu\h'+03'\c
61 .\}
62 .el \{\
63 .sp -1
64 .IP \(bu 2.3
65 .\}
66 Creating / Uploading a CL
67 .RE
68 .sp
69 .RS 4
70 .ie n \{\
71 \h'-04'\(bu\h'+03'\c
72 .\}
73 .el \{\
74 .sp -1
75 .IP \(bu 2.3
76 .\}
77 Updating the code
78 .RE
79 .sp
80 .RS 4
81 .ie n \{\
82 \h'-04'\(bu\h'+03'\c
83 .\}
84 .el \{\
85 .sp -1
86 .IP \(bu 2.3
87 .\}
88 Managing multiple CLs
89 .RE
90 .sp
91 .RS 4
92 .ie n \{\
93 \h'-04'\(bu\h'+03'\c
94 .\}
95 .el \{\
96 .sp -1
97 .IP \(bu 2.3
98 .\}
99 Managing dependent CLs
100 .RE
101 .sp
102 Please refer to the manpages (or \-\-help output) for details about any of the c ommands mentioned in this tutorial\&.
103 .if n \{\
104 .sp
105 .\}
106 .RS 4
107 .it 1 an-trap
108 .nr an-no-space-flag 1
109 .nr an-break-flag 1
110 .br
111 .ps +1
112 \fBNote\fR
113 .ps -1
114 .br
115 .sp
116 If your platform does not support manpages (or you prefer something a bit more e xpressive than plain text) you can find all documentation in \fIhtml\fR form in the [DEPOT_TOOLS]/docs/html folder\&.
117 .sp .5v
118 .RE
119 .SS "PREREQUISITES"
120 .sp
121 This tutorial will assume some basic familarity with git terminology and basic p remises\&. If you need to brush up on these, the following are very good resourc es:
122 .sp
123 .RS 4
124 .ie n \{\
125 \h'-04'\(bu\h'+03'\c
126 .\}
127 .el \{\
128 .sp -1
129 .IP \(bu 2.3
130 .\}
131 \m[blue]\fBPro Git book\fR\m[]\&\s-2\u[1]\d\s+2
132 \- Pretty good overview of git to bootstrap a working knowledge\&.
133 .RE
134 .sp
135 .RS 4
136 .ie n \{\
137 \h'-04'\(bu\h'+03'\c
138 .\}
139 .el \{\
140 .sp -1
141 .IP \(bu 2.3
142 .\}
143 \m[blue]\fBGit Immersion Tutorial\fR\m[]\&\s-2\u[2]\d\s+2
144 \- An in\-depth git tutorial\&.
145 .RE
146 .sp
147 .RS 4
148 .ie n \{\
149 \h'-04'\(bu\h'+03'\c
150 .\}
151 .el \{\
152 .sp -1
153 .IP \(bu 2.3
154 .\}
155 \m[blue]\fBpcottle\(cqs Visual Git Branching\fR\m[]\&\s-2\u[3]\d\s+2
156 \- An excellent interactive/graphical demo on how git handles commits, branches, and shows the operations git performs on them\&.
157 .RE
158 .SH "SETTING UP"
159 .SS "GET DEPOT TOOLS"
160 .sp
161 Clone the \fIdepot_tools\fR repository:
162 .sp
163 .if n \{\
164 .RS 4
165 .\}
166 .nf
167 \fB$ git clone https://chromium\&.googlesource\&.com/chromium/tools/depot_tools\ fR
168 .fi
169 .if n \{\
170 .RE
171 .\}
172 .sp
173 .sp
174 Add \fIdepot_tools\fR to the \fIend\fR of your PATH and MANPATH (you will probab ly want to put this in your ~/\&.bashrc or ~/\&.zshrc)\&. Assuming you cloned \f Idepot_tools\fR to /path/to/depot_tools:
175 .sp
176 .if n \{\
177 .RS 4
178 .\}
179 .nf
180 \fB$ export PATH=$PATH:/path/to/depot_tools\fR
181 \fB$ export MANPATH=$MANPATH:/path/to/depot_tools/docs\fR \fB(1)\fR
182 .fi
183 .if n \{\
184 .RE
185 .\}
186 .sp
187 .sp
188 \fB1. \fRObserve that this path is
189 depot_tools/\fBdocs\fR\&.
190 .br
191 .SS "BOOTSTRAPPING CONFIGURATION"
192 .sp
193 If you have never used git before, you\(cqll need to set some global git configu rations; substitute your name and email address in the following commands:
194 .sp
195 .if n \{\
196 .RS 4
197 .\}
198 .nf
199 \fB$ git config \-\-global user\&.name \(lqJohn Doe\(rq\fR
200 \fB$ git config \-\-global user\&.email \(lqjdoe@email\&.com\(rq\fR
201 \fB$ git config \-\-global core\&.autocrlf false\fR
202 \fB$ git config \-\-global core\&.filemode false\fR
203 \fB$\fR # and for fun!
204 \fB$ git config \-\-global color\&.ui true\fR
205 .fi
206 .if n \{\
207 .RE
208 .\}
209 .sp
210 .SH "GETTING THE CODE"
211 .sp
212 Pick an empty directory and run one of the following:
213 .sp
214 .if n \{\
215 .RS 4
216 .\}
217 .nf
218 \fB$ fetch chromium\fR # Basic checkout for desktop Chromium
219 \fB$ fetch blink\fR # Chromium code with blink checked out to tip\-of\-tree
220 \fB$ fetch android\fR # Chromium checkout for Android platform
221 \fB$ fetch ios\fR # Chromium checkout for iOS platform
222 .fi
223 .if n \{\
224 .RE
225 .\}
226 .sp
227 .sp
228 When the fetch tool completes you should have the following in your working dire ctory:
229 .sp
230 .if n \{\
231 .RS 4
232 .\}
233 .nf
234 \fB\&.gclient\fR # A configuration file for you source checkout
235 \fBsrc/\fR # Top\-level Chromium source checkout\&.
236 .fi
237 .if n \{\
238 .RE
239 .\}
240 .sp
241 .sp
242 If you are on linux, then you\(cqll need to run:
243 .sp
244 .if n \{\
245 .RS 4
246 .\}
247 .nf
248 \fB$ cd src && \&./build/install\-build\-deps\&.sh\fR
249 .fi
250 .if n \{\
251 .RE
252 .\}
253 .sp
254 .sp
255 And finally:
256 .sp
257 .if n \{\
258 .RS 4
259 .\}
260 .nf
261 \fB$ gclient sync\fR \fB(1)\fR
262 .fi
263 .if n \{\
264 .RE
265 .\}
266 .sp
267 .sp
268 \fB1. \fRThis will pull all dependencies of the Chromium src checkout\&. You wil l need to run this any time you update the main src checkout\&.
269 .br
270 .SH "CREATING / UPLOADING A CL"
271 .if n \{\
272 .sp
273 .\}
274 .RS 4
275 .it 1 an-trap
276 .nr an-no-space-flag 1
277 .nr an-break-flag 1
278 .br
279 .ps +1
280 \fBNote\fR
281 .ps -1
282 .br
283 .sp
284 The remainder of the tutorial assumes that your current working directory is the src/ folder mentioned in Getting the code\&.
285 .sp .5v
286 .RE
287 .sp
288 Each CL corresponds exactly with a single branch in git\&. Any time you want to begin a new CL, just:
289 .sp
290 .if n \{\
291 .RS 4
292 .\}
293 .nf
294 \fB$ git new\-branch <branch_name>\fR
295 .fi
296 .if n \{\
297 .RE
298 .\}
299 .sp
300 .sp
301 This will create and checkout a new branch named branch_name which will track th e default upstream (which is origin/master)\&. See \fBgit-new-branch\fR(1) for m ore features, such as the ability to track \fILKGR\fR\&.
302 .sp
303 Commit as many changes as you like to this branch\&. When you want to upload it for review, run:
304 .sp
305 .if n \{\
306 .RS 4
307 .\}
308 .nf
309 \fB$ git cl upload\fR
310 .fi
311 .if n \{\
312 .RE
313 .\}
314 .sp
315 .sp
316 This will take the diff of your branch against it\(cqs upstream (origin/master), and will post it to the \m[blue]\fBChromium code review site\fR\m[]\&\s-2\u[4]\ d\s+2\&.
317 .SH "UPDATING THE CODE"
318 .sp
319 Inevitably, you\(cqll want to pull in changes from the main Chromium repo\&. Thi s is pretty easy with \fIdepot_tools\fR:
320 .sp
321 .if n \{\
322 .RS 4
323 .\}
324 .nf
325 \fB$ git rebase\-update\fR
326 .fi
327 .if n \{\
328 .RE
329 .\}
330 .sp
331 .sp
332 This command will update all of your CLs to contain the latest code from their u pstreams\&. It will also automatically clean up CLs which have been committed an d a couple other nice things :)\&. See \fBgit-rebase-update\fR(1) for the full s coop\&.
333 .sp
334 One thing to look out for are \fImerge conflicts\fR\&. These happen for exactly the same as they do with SVN, but the experience is a little more controllable w ith git\&. git rebase\-update will try to rebase all your branches for you, but if it encounters a merge conflict in one, it will halt and leave you in a rebase conflict state (see \fBgit-rebase\fR(1))\&. Resolving git rebase merge conflict s is beyond the scope of this tutorial, but there are many good sources online ( see the Prerequisites for some)\&.
335 .sp
336 Sometimes you\(cqre pretty certain that you\(cqve committed a certain branch, bu t git rebase\-update isn\(cqt able to tell that because your branch doesn\(cqt r ebase cleanly, and you\(cqd like to double check the diff of your branch against its upstream before deleting it\&. If this is the case you can abort the rebase , and then run \fBgit-squash-branch\fR(1) to flatten your branch into a single c ommit\&. When you run git rebase\-update again, you\(cqll get a (hopefully) much smaller / saner diff\&. If it turns out you were wrong, you can use \fBgit-refl og\fR(1) to reset your branch back to where it was\&.
337 .sp
338 Once you\(cqre done resolving all of the merge conflict, just run git rebase\-up date, and it will pick up where it left off\&. Once the command has finished upd ating all of your branches, it will return you back to the branch you started on \&.
339 .if n \{\
340 .sp
341 .\}
342 .RS 4
343 .it 1 an-trap
344 .nr an-no-space-flag 1
345 .nr an-break-flag 1
346 .br
347 .ps +1
348 \fBNote\fR
349 .ps -1
350 .br
351 .sp
352 Running git rebase\-update will update all your branches, but it will not automa tically run gclient sync to update your dependencies\&.
353 .sp .5v
354 .RE
355 .SH "MANAGING MULTIPLE CLS"
356 .sp
357 Sometimes you want to work on more than one CL at once (say, you have a CL poste d for review and want to work on something else)\&. For each CL that you want to work on, just use git new\-branch <branchname>\&.
358 .sp
359 Once you start to have more than one CL at a time, it can be easy to lose your b earings\&. Fortunately, \fIdepot_tools\fR has two tools to help you out:
360 .sp
361 .if n \{\
362 .RS 4
363 .\}
364 .nf
365 \fB$ git map\fR
366 *\:\fB 7dcfe47 \fR (\:\fBfrozen_changes\fR\:) 2014\-03\-12 ~ FREEZE\&.unin dexed
367 * \fB4b0c180\fR 2014\-03\-12 ~ modfile
368 * \fB59a7cca\fR 2014\-03\-12 ~ a deleted file
369 * \fB6bec695\fR (\:origin/master\:) 2014\-03\-11 ~ Add neat feature \f B<(frozen_changes)\fR
370 * \fBd15a38a\fR 2014\-03\-11 ~ Epic README update
371 * \fBd559894\fR (\:\fBmaster\fR\:) 2014\-03\-11 ~ Important upstream chan ge
372 | * \fB9c311fd\fR (\:\fBcool_feature\fR\:) 2014\-03\-11 ~ Respond to CL com ments
373 | | * \fB2a1eeb2\fR (\:\fBsubfeature\fR\:) 2014\-03\-11 ~ integrate with Cool Service
374 | | * \fBd777af6\fR 2014\-03\-11 ~ slick commenting action
375 | |/
376 | * \fB265803a\fR 2014\-03\-11 ~ another improvement \fB<(subfeature)\fR
377 | * \fB6d831ac\fR (\:\fBspleen_tag\fR\:) 2014\-03\-11 ~ Refactor spleen
378 | * \fB82e74ab\fR 2014\-03\-11 ~ Add widget
379 |/
380 * \fBd08c5b3\fR (\:\fBbogus_noparent\fR\:) 2014\-03\-11 ~ Wonderful begin nings \fB<(cool_feature)\fR
381 .fi
382 .if n \{\
383 .RE
384 .\}
385 .sp
386 .sp
387 Note that this example repo is in dire need of a \fBgit-rebase-update\fR(1)!
388 .sp
389 .if n \{\
390 .RS 4
391 .\}
392 .nf
393 \fB$ git map\-branches\fR
394 origin/master
395 cool_feature
396 subfeature
397 frozen_changes *
398 master
399 .fi
400 .if n \{\
401 .RE
402 .\}
403 .sp
404
405 .PP
406 \fBgit-map\fR(1)
407 .RS 4
408 This tool shows you the history of all of your branches in a pseudo\-graphical f ormat\&. In particular, it will show you which commits all of your branches are on, which commit you currently have checked out, and more\&. Check out the doc f or the full details\&.
409 .RE
410 .PP
411 \fBgit-map-branches\fR(1)
412 .RS 4
413 This tool just shows you which branches you have in your repo, and thier upstrea m relationship to each other (as well as which branch you have checked out at th e moment)\&.
414 .RE
415 .sp
416 Additionally, sometimes you need to switch between branches, but you\(cqve got w ork in progress\&. You could use \fBgit-stash\fR(1), but that can be tricky to m anage because you need to remember which branches you stashed what changes on\&. Helpfully \fIdepot_tools\fR includes two tools which can greatly assist in case :
417 .sp
418 \fBgit-freeze\fR(1) allows you to put the current branch in \*(Aqsuspended anima tion\*(Aq by committing your changes to a specially\-named commit on the top of your current branch\&. When you come back to your branch later, you can just run \fBgit-thaw\fR(1) to get your work\-in\-progress changes back to what they were \&.
419 .sp
420 Another useful tool is \fBgit-rename-branch\fR(1)\&. No, I\(cqm not going to exp lain what it does\&.
421 .sp
422 Finally, take a look at \fBgit-upstream-diff\fR(1)\&. This will show you the com bined diff for all the commits on your branch against the upstream tracking bran ch\&. This is \fIexactly\fR what git cl upload will push up to code review\&. Ad ditionally, consider trying the \-\-wordwise argument to get a colorized per\-wo rd diff (instead of a per\-line diff)\&.
423 .SH "MANAGING DEPENDENT CLS"
424 .sp
425 Now that you know how to manage \fIindependent\fR CLs, we\(cqll see how to manag e \fIdependent\fR CLs\&. Dependent CLs are useful when your second (or third or fourth or \&...) CL depends on the changes in one of your other CLs (such as: CL 2 won\(cqt compile without CL 1, but you want to submit them as two separate re views)\&.
426 .sp
427 Like all of the other CLs we\(cqve created, we use \fBgit-new-branch\fR(1), but this time with a (not very surprising) twist\&. First, git checkout the branch y ou want to base the new one on (i\&.e\&. CL 1), and then run:
428 .sp
429 .if n \{\
430 .RS 4
431 .\}
432 .nf
433 \fB$ git new\-branch \-\-upstream_current <branch_name>\fR
434 .fi
435 .if n \{\
436 .RE
437 .\}
438 .sp
439 .sp
440 This will make a new branch which tracks the \fIcurrent\fR branch as its upstrea m (as opposed to \fIorigin/master\fR)\&. All changes you commit to this branch w ill be in addition to the previous branch, but when you git cl upload, you will only upload the diff for the dependent (child) branch\&. You may have as many br anches nested in this fashion as you like\&.
441 .sp
442 \fBgit-map\fR(1) and \fBgit-map-branches\fR(1) are particularly helpful when you have dependent branches\&. In addition, there are two helper commands which let you traverse your working copy up and down this tree of branches: \fBgit-nav-up stream\fR(1) and \fBgit-nav-downstream\fR(1)\&.
443 .sp
444 Sometimes when dealing with dependent CLs, it turns out that you accidentally ba sed a branch on the wrong upstream, but since then you\(cqve committed changes t o it, or even based \fIanother\fR branch off of that one\&. Or say that you have two independent CLs that would actually be much better off as dependent CLs\&. Not to worry, because you can just check out the offending branch and use \fBgit -reparent-branch\fR(1) to move it around the tree\&.
445 .SH "CONCLUSION"
446 .sp
447 Well that wraps up the whirlwind tour of the \fIdepot_tools\fR helper tools\&. I f you have questions which weren\(cqt answered by this tutorial or the man pages for the tools (see the index of all tools here: \fBdepot_tools\fR(7)), please a sk :)\&.
448 .SH "GLOSSARY"
449 .PP
450 CL
451 .RS 4
452 A
453 \fIchange\-list\fR\&. This is a diff which you would like to commit to the codeb ase\&.
454 .RE
455 .PP
456 DEPS
457 .RS 4
458 A file in the chromium checkout which
459 gclient sync
460 uses to determine what dependencies to pull in\&. This file also contains
461 \fIhooks\fR\&.
462 .RE
463 .PP
464 LKGR
465 .RS 4
466 Last Known Good Revision\&. This is a
467 \fBgit-tag\fR(1)
468 which tracks the last version of
469 origin/master
470 which has passed the full set of testing on the
471 \m[blue]\fBmain Chromium waterfall\fR\m[]\&\s-2\u[5]\d\s+2\&.
472 .RE
473 .SH "CHROMIUM DEPOT_TOOLS"
474 .sp
475 Part of the chromium \fBdepot_tools\fR(7) suite\&. These tools are meant to assi st with the development of chromium and related projects\&. Download the tools f rom \m[blue]\fBhere\fR\m[]\&\s-2\u[6]\d\s+2\&.
476 .SH "NOTES"
477 .IP " 1." 4
478 Pro Git book
479 .RS 4
480 \%http://git-scm.com/book
481 .RE
482 .IP " 2." 4
483 Git Immersion Tutorial
484 .RS 4
485 \%http://gitimmersion.com/
486 .RE
487 .IP " 3." 4
488 pcottle\(cqs Visual Git Branching
489 .RS 4
490 \%http://pcottle.github.io/learnGitBranching
491 .RE
492 .IP " 4." 4
493 Chromium code review site
494 .RS 4
495 \%https://codereview.chromium.org
496 .RE
497 .IP " 5." 4
498 main Chromium waterfall
499 .RS 4
500 \%http://build.chromium.org
501 .RE
502 .IP " 6." 4
503 here
504 .RS 4
505 \%https://chromium.googlesource.com/chromium/tools/depot_tools.git
506 .RE
OLDNEW
« no previous file with comments | « docs/man7/depot_tools.7 ('k') | docs/src/_footer.txt » ('j') | docs/src/depot_tools_tutorial.txt » ('J')

Powered by Google App Engine
This is Rietveld 408576698