OSDN Git Service

Add Git official document to help
[tortoisegit/TortoiseGitJp.git] / doc / source / en / TortoiseGit / git_doc / everyday.xml
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">\r
3 \r
4 <article lang="en" id="Everyday GIT With 20 Commands Or So">\r
5 <articleinfo>\r
6     <title>Everyday GIT With 20 Commands Or So</title>\r
7         <indexterm>\r
8                 <primary>Everyday GIT With 20 Commands Or So</primary>\r
9         </indexterm>\r
10 </articleinfo>\r
11 <simpara><xref linkend="Basic Repository"/> commands are needed by people who have a\r
12 repository --- that is everybody, because every working tree of\r
13 git is a repository.</simpara>\r
14 <simpara>In addition, <xref linkend="Individual Developer (Standalone)"/> commands are\r
15 essential for anybody who makes a commit, even for somebody who\r
16 works alone.</simpara>\r
17 <simpara>If you work with other people, you will need commands listed in\r
18 the <xref linkend="Individual Developer (Participant)"/> section as well.</simpara>\r
19 <simpara>People who play the <xref linkend="Integrator"/> role need to learn some more\r
20 commands in addition to the above.</simpara>\r
21 <simpara><xref linkend="Repository Administration"/> commands are for system\r
22 administrators who are responsible for the care and feeding\r
23 of git repositories.</simpara>\r
24 <simplesect id="_basic_repository_anchor_id_basic_repository_xreflabel_basic_repository">\r
25 <title>Basic Repository<anchor id="Basic Repository" xreflabel="[Basic Repository]"/></title>\r
26 <simpara>Everybody uses these commands to maintain git repositories.</simpara>\r
27 <itemizedlist>\r
28 <listitem>\r
29 <simpara>\r
30 <xref linkend="git-init(1)"/> or <xref linkend="git-clone(1)"/> to create a\r
31     new repository.\r
32 </simpara>\r
33 </listitem>\r
34 <listitem>\r
35 <simpara>\r
36 <xref linkend="git-fsck(1)"/> to check the repository for errors.\r
37 </simpara>\r
38 </listitem>\r
39 <listitem>\r
40 <simpara>\r
41 <xref linkend="git-gc(1)"/> to do common housekeeping tasks such as\r
42     repack and prune.\r
43 </simpara>\r
44 </listitem>\r
45 </itemizedlist>\r
46 <simplesect id="_examples">\r
47 <title>Examples</title>\r
48 <variablelist>\r
49 <varlistentry>\r
50 <term>\r
51 Check health and remove cruft.\r
52 </term>\r
53 <listitem>\r
54 <literallayout>$ git fsck <co id="CO1-1"/>\r
55 $ git count-objects <co id="CO1-2"/>\r
56 $ git gc <co id="CO1-3"/></literallayout>\r
57 <calloutlist>\r
58 <callout arearefs="CO1-1">\r
59 <simpara>\r
60 running without <literal>--full</literal> is usually cheap and assures the\r
61 repository health reasonably well.\r
62 </simpara>\r
63 </callout>\r
64 <callout arearefs="CO1-2">\r
65 <simpara>\r
66 check how many loose objects there are and how much\r
67 disk space is wasted by not repacking.\r
68 </simpara>\r
69 </callout>\r
70 <callout arearefs="CO1-3">\r
71 <simpara>\r
72 repacks the local repository and performs other housekeeping tasks.\r
73 </simpara>\r
74 </callout>\r
75 </calloutlist>\r
76 </listitem>\r
77 </varlistentry>\r
78 <varlistentry>\r
79 <term>\r
80 Repack a small project into single pack.\r
81 </term>\r
82 <listitem>\r
83 <literallayout>$ git gc <co id="CO2-1"/></literallayout>\r
84 <calloutlist>\r
85 <callout arearefs="CO2-1">\r
86 <simpara>\r
87 pack all the objects reachable from the refs into one pack,\r
88 then remove the other packs.\r
89 </simpara>\r
90 </callout>\r
91 </calloutlist>\r
92 </listitem>\r
93 </varlistentry>\r
94 </variablelist>\r
95 </simplesect>\r
96 </simplesect>\r
97 <simplesect id="_individual_developer_standalone_anchor_id_individual_developer_standalone_xreflabel_individual_developer_standalone">\r
98 <title>Individual Developer (Standalone)<anchor id="Individual Developer (Standalone)" xreflabel="[Individual Developer (Standalone)]"/></title>\r
99 <simpara>A standalone individual developer does not exchange patches with\r
100 other people, and works alone in a single repository, using the\r
101 following commands.</simpara>\r
102 <itemizedlist>\r
103 <listitem>\r
104 <simpara>\r
105 <xref linkend="git-show-branch(1)"/> to see where you are.\r
106 </simpara>\r
107 </listitem>\r
108 <listitem>\r
109 <simpara>\r
110 <xref linkend="git-log(1)"/> to see what happened.\r
111 </simpara>\r
112 </listitem>\r
113 <listitem>\r
114 <simpara>\r
115 <xref linkend="git-checkout(1)"/> and <xref linkend="git-branch(1)"/> to switch\r
116     branches.\r
117 </simpara>\r
118 </listitem>\r
119 <listitem>\r
120 <simpara>\r
121 <xref linkend="git-add(1)"/> to manage the index file.\r
122 </simpara>\r
123 </listitem>\r
124 <listitem>\r
125 <simpara>\r
126 <xref linkend="git-diff(1)"/> and <xref linkend="git-status(1)"/> to see what\r
127     you are in the middle of doing.\r
128 </simpara>\r
129 </listitem>\r
130 <listitem>\r
131 <simpara>\r
132 <xref linkend="git-commit(1)"/> to advance the current branch.\r
133 </simpara>\r
134 </listitem>\r
135 <listitem>\r
136 <simpara>\r
137 <xref linkend="git-reset(1)"/> and <xref linkend="git-checkout(1)"/> (with\r
138     pathname parameters) to undo changes.\r
139 </simpara>\r
140 </listitem>\r
141 <listitem>\r
142 <simpara>\r
143 <xref linkend="git-merge(1)"/> to merge between local branches.\r
144 </simpara>\r
145 </listitem>\r
146 <listitem>\r
147 <simpara>\r
148 <xref linkend="git-rebase(1)"/> to maintain topic branches.\r
149 </simpara>\r
150 </listitem>\r
151 <listitem>\r
152 <simpara>\r
153 <xref linkend="git-tag(1)"/> to mark known point.\r
154 </simpara>\r
155 </listitem>\r
156 </itemizedlist>\r
157 <simplesect id="_examples_2">\r
158 <title>Examples</title>\r
159 <variablelist>\r
160 <varlistentry>\r
161 <term>\r
162 Use a tarball as a starting point for a new repository.\r
163 </term>\r
164 <listitem>\r
165 <literallayout>$ tar zxf frotz.tar.gz\r
166 $ cd frotz\r
167 $ git-init\r
168 $ git add . <co id="CO3-1"/>\r
169 $ git commit -m "import of frotz source tree."\r
170 $ git tag v2.43 <co id="CO3-2"/></literallayout>\r
171 <calloutlist>\r
172 <callout arearefs="CO3-1">\r
173 <simpara>\r
174 add everything under the current directory.\r
175 </simpara>\r
176 </callout>\r
177 <callout arearefs="CO3-2">\r
178 <simpara>\r
179 make a lightweight, unannotated tag.\r
180 </simpara>\r
181 </callout>\r
182 </calloutlist>\r
183 </listitem>\r
184 </varlistentry>\r
185 <varlistentry>\r
186 <term>\r
187 Create a topic branch and develop.\r
188 </term>\r
189 <listitem>\r
190 <literallayout>$ git checkout -b alsa-audio <co id="CO4-1"/>\r
191 $ edit/compile/test\r
192 $ git checkout -- curses/ux_audio_oss.c <co id="CO4-2"/>\r
193 $ git add curses/ux_audio_alsa.c <co id="CO4-3"/>\r
194 $ edit/compile/test\r
195 $ git diff HEAD <co id="CO4-4"/>\r
196 $ git commit -a -s <co id="CO4-5"/>\r
197 $ edit/compile/test\r
198 $ git reset --soft HEAD^ <co id="CO4-6"/>\r
199 $ edit/compile/test\r
200 $ git diff ORIG_HEAD <co id="CO4-7"/>\r
201 $ git commit -a -c ORIG_HEAD <co id="CO4-8"/>\r
202 $ git checkout master <co id="CO4-9"/>\r
203 $ git merge alsa-audio <co id="CO4-10"/>\r
204 $ git log --since='3 days ago' <co id="CO4-11"/>\r
205 $ git log v2.43.. curses/ <co id="CO4-12"/></literallayout>\r
206 <calloutlist>\r
207 <callout arearefs="CO4-1">\r
208 <simpara>\r
209 create a new topic branch.\r
210 </simpara>\r
211 </callout>\r
212 <callout arearefs="CO4-2">\r
213 <simpara>\r
214 revert your botched changes in <literal>curses/ux_audio_oss.c</literal>.\r
215 </simpara>\r
216 </callout>\r
217 <callout arearefs="CO4-3">\r
218 <simpara>\r
219 you need to tell git if you added a new file; removal and\r
220 modification will be caught if you do <literal>git commit -a</literal> later.\r
221 </simpara>\r
222 </callout>\r
223 <callout arearefs="CO4-4">\r
224 <simpara>\r
225 to see what changes you are committing.\r
226 </simpara>\r
227 </callout>\r
228 <callout arearefs="CO4-5">\r
229 <simpara>\r
230 commit everything as you have tested, with your sign-off.\r
231 </simpara>\r
232 </callout>\r
233 <callout arearefs="CO4-6">\r
234 <simpara>\r
235 take the last commit back, keeping what is in the working tree.\r
236 </simpara>\r
237 </callout>\r
238 <callout arearefs="CO4-7">\r
239 <simpara>\r
240 look at the changes since the premature commit we took back.\r
241 </simpara>\r
242 </callout>\r
243 <callout arearefs="CO4-8">\r
244 <simpara>\r
245 redo the commit undone in the previous step, using the message\r
246 you originally wrote.\r
247 </simpara>\r
248 </callout>\r
249 <callout arearefs="CO4-9">\r
250 <simpara>\r
251 switch to the master branch.\r
252 </simpara>\r
253 </callout>\r
254 <callout arearefs="CO4-10">\r
255 <simpara>\r
256 merge a topic branch into your master branch.\r
257 </simpara>\r
258 </callout>\r
259 <callout arearefs="CO4-11">\r
260 <simpara>\r
261 review commit logs; other forms to limit output can be\r
262 combined and include <literal>--max-count=10</literal> (show 10 commits),\r
263 <literal>--until=2005-12-10</literal>, etc.\r
264 </simpara>\r
265 </callout>\r
266 <callout arearefs="CO4-12">\r
267 <simpara>\r
268 view only the changes that touch what&#8217;s in <literal>curses/</literal>\r
269 directory, since <literal>v2.43</literal> tag.\r
270 </simpara>\r
271 </callout>\r
272 </calloutlist>\r
273 </listitem>\r
274 </varlistentry>\r
275 </variablelist>\r
276 </simplesect>\r
277 </simplesect>\r
278 <simplesect id="_individual_developer_participant_anchor_id_individual_developer_participant_xreflabel_individual_developer_participant">\r
279 <title>Individual Developer (Participant)<anchor id="Individual Developer (Participant)" xreflabel="[Individual Developer (Participant)]"/></title>\r
280 <simpara>A developer working as a participant in a group project needs to\r
281 learn how to communicate with others, and uses these commands in\r
282 addition to the ones needed by a standalone developer.</simpara>\r
283 <itemizedlist>\r
284 <listitem>\r
285 <simpara>\r
286 <xref linkend="git-clone(1)"/> from the upstream to prime your local\r
287     repository.\r
288 </simpara>\r
289 </listitem>\r
290 <listitem>\r
291 <simpara>\r
292 <xref linkend="git-pull(1)"/> and <xref linkend="git-fetch(1)"/> from "origin"\r
293     to keep up-to-date with the upstream.\r
294 </simpara>\r
295 </listitem>\r
296 <listitem>\r
297 <simpara>\r
298 <xref linkend="git-push(1)"/> to shared repository, if you adopt CVS\r
299     style shared repository workflow.\r
300 </simpara>\r
301 </listitem>\r
302 <listitem>\r
303 <simpara>\r
304 <xref linkend="git-format-patch(1)"/> to prepare e-mail submission, if\r
305     you adopt Linux kernel-style public forum workflow.\r
306 </simpara>\r
307 </listitem>\r
308 </itemizedlist>\r
309 <simplesect id="_examples_3">\r
310 <title>Examples</title>\r
311 <variablelist>\r
312 <varlistentry>\r
313 <term>\r
314 Clone the upstream and work on it.  Feed changes to upstream.\r
315 </term>\r
316 <listitem>\r
317 <literallayout>$ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6\r
318 $ cd my2.6\r
319 $ edit/compile/test; git commit -a -s <co id="CO5-1"/>\r
320 $ git format-patch origin <co id="CO5-2"/>\r
321 $ git pull <co id="CO5-3"/>\r
322 $ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 <co id="CO5-4"/>\r
323 $ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <co id="CO5-5"/>\r
324 $ git reset --hard ORIG_HEAD <co id="CO5-6"/>\r
325 $ git gc <co id="CO5-7"/>\r
326 $ git fetch --tags <co id="CO5-8"/></literallayout>\r
327 <calloutlist>\r
328 <callout arearefs="CO5-1">\r
329 <simpara>\r
330 repeat as needed.\r
331 </simpara>\r
332 </callout>\r
333 <callout arearefs="CO5-2">\r
334 <simpara>\r
335 extract patches from your branch for e-mail submission.\r
336 </simpara>\r
337 </callout>\r
338 <callout arearefs="CO5-3">\r
339 <simpara>\r
340 <literal>git pull</literal> fetches from <literal>origin</literal> by default and merges into the\r
341 current branch.\r
342 </simpara>\r
343 </callout>\r
344 <callout arearefs="CO5-4">\r
345 <simpara>\r
346 immediately after pulling, look at the changes done upstream\r
347 since last time we checked, only in the\r
348 area we are interested in.\r
349 </simpara>\r
350 </callout>\r
351 <callout arearefs="CO5-5">\r
352 <simpara>\r
353 fetch from a specific branch from a specific repository and merge.\r
354 </simpara>\r
355 </callout>\r
356 <callout arearefs="CO5-6">\r
357 <simpara>\r
358 revert the pull.\r
359 </simpara>\r
360 </callout>\r
361 <callout arearefs="CO5-7">\r
362 <simpara>\r
363 garbage collect leftover objects from reverted pull.\r
364 </simpara>\r
365 </callout>\r
366 <callout arearefs="CO5-8">\r
367 <simpara>\r
368 from time to time, obtain official tags from the <literal>origin</literal>\r
369 and store them under <literal>.git/refs/tags/</literal>.\r
370 </simpara>\r
371 </callout>\r
372 </calloutlist>\r
373 </listitem>\r
374 </varlistentry>\r
375 <varlistentry>\r
376 <term>\r
377 Push into another repository.\r
378 </term>\r
379 <listitem>\r
380 <literallayout>satellite$ git clone mothership:frotz frotz <co id="CO6-1"/>\r
381 satellite$ cd frotz\r
382 satellite$ git config --get-regexp '^(remote|branch)\.' <co id="CO6-2"/>\r
383 remote.origin.url mothership:frotz\r
384 remote.origin.fetch refs/heads/*:refs/remotes/origin/*\r
385 branch.master.remote origin\r
386 branch.master.merge refs/heads/master\r
387 satellite$ git config remote.origin.push \\r
388            master:refs/remotes/satellite/master <co id="CO6-3"/>\r
389 satellite$ edit/compile/test/commit\r
390 satellite$ git push origin <co id="CO6-4"/>\r
391 \r
392 mothership$ cd frotz\r
393 mothership$ git checkout master\r
394 mothership$ git merge satellite/master <co id="CO6-5"/></literallayout>\r
395 <calloutlist>\r
396 <callout arearefs="CO6-1">\r
397 <simpara>\r
398 mothership machine has a frotz repository under your home\r
399 directory; clone from it to start a repository on the satellite\r
400 machine.\r
401 </simpara>\r
402 </callout>\r
403 <callout arearefs="CO6-2">\r
404 <simpara>\r
405 clone sets these configuration variables by default.\r
406 It arranges <literal>git pull</literal> to fetch and store the branches of mothership\r
407 machine to local <literal>remotes/origin/*</literal> tracking branches.\r
408 </simpara>\r
409 </callout>\r
410 <callout arearefs="CO6-3">\r
411 <simpara>\r
412 arrange <literal>git push</literal> to push local <literal>master</literal> branch to\r
413 <literal>remotes/satellite/master</literal> branch of the mothership machine.\r
414 </simpara>\r
415 </callout>\r
416 <callout arearefs="CO6-4">\r
417 <simpara>\r
418 push will stash our work away on <literal>remotes/satellite/master</literal>\r
419 tracking branch on the mothership machine.  You could use this as\r
420 a back-up method.\r
421 </simpara>\r
422 </callout>\r
423 <callout arearefs="CO6-5">\r
424 <simpara>\r
425 on mothership machine, merge the work done on the satellite\r
426 machine into the master branch.\r
427 </simpara>\r
428 </callout>\r
429 </calloutlist>\r
430 </listitem>\r
431 </varlistentry>\r
432 <varlistentry>\r
433 <term>\r
434 Branch off of a specific tag.\r
435 </term>\r
436 <listitem>\r
437 <literallayout>$ git checkout -b private2.6.14 v2.6.14 <co id="CO7-1"/>\r
438 $ edit/compile/test; git commit -a\r
439 $ git checkout master\r
440 $ git format-patch -k -m --stdout v2.6.14..private2.6.14 |\r
441   git am -3 -k <co id="CO7-2"/></literallayout>\r
442 <calloutlist>\r
443 <callout arearefs="CO7-1">\r
444 <simpara>\r
445 create a private branch based on a well known (but somewhat behind)\r
446 tag.\r
447 </simpara>\r
448 </callout>\r
449 <callout arearefs="CO7-2">\r
450 <simpara>\r
451 forward port all changes in <literal>private2.6.14</literal> branch to <literal>master</literal> branch\r
452 without a formal "merging".\r
453 </simpara>\r
454 </callout>\r
455 </calloutlist>\r
456 </listitem>\r
457 </varlistentry>\r
458 </variablelist>\r
459 </simplesect>\r
460 </simplesect>\r
461 <simplesect id="_integrator_anchor_id_integrator_xreflabel_integrator">\r
462 <title>Integrator<anchor id="Integrator" xreflabel="[Integrator]"/></title>\r
463 <simpara>A fairly central person acting as the integrator in a group\r
464 project receives changes made by others, reviews and integrates\r
465 them and publishes the result for others to use, using these\r
466 commands in addition to the ones needed by participants.</simpara>\r
467 <itemizedlist>\r
468 <listitem>\r
469 <simpara>\r
470 <xref linkend="git-am(1)"/> to apply patches e-mailed in from your\r
471     contributors.\r
472 </simpara>\r
473 </listitem>\r
474 <listitem>\r
475 <simpara>\r
476 <xref linkend="git-pull(1)"/> to merge from your trusted lieutenants.\r
477 </simpara>\r
478 </listitem>\r
479 <listitem>\r
480 <simpara>\r
481 <xref linkend="git-format-patch(1)"/> to prepare and send suggested\r
482     alternative to contributors.\r
483 </simpara>\r
484 </listitem>\r
485 <listitem>\r
486 <simpara>\r
487 <xref linkend="git-revert(1)"/> to undo botched commits.\r
488 </simpara>\r
489 </listitem>\r
490 <listitem>\r
491 <simpara>\r
492 <xref linkend="git-push(1)"/> to publish the bleeding edge.\r
493 </simpara>\r
494 </listitem>\r
495 </itemizedlist>\r
496 <simplesect id="_examples_4">\r
497 <title>Examples</title>\r
498 <variablelist>\r
499 <varlistentry>\r
500 <term>\r
501 My typical GIT day.\r
502 </term>\r
503 <listitem>\r
504 <literallayout>$ git status <co id="CO8-1"/>\r
505 $ git show-branch <co id="CO8-2"/>\r
506 $ mailx <co id="CO8-3"/>\r
507 &amp; s 2 3 4 5 ./+to-apply\r
508 &amp; s 7 8 ./+hold-linus\r
509 &amp; q\r
510 $ git checkout -b topic/one master\r
511 $ git am -3 -i -s -u ./+to-apply <co id="CO8-4"/>\r
512 $ compile/test\r
513 $ git checkout -b hold/linus &amp;&amp; git am -3 -i -s -u ./+hold-linus <co id="CO8-5"/>\r
514 $ git checkout topic/one &amp;&amp; git rebase master <co id="CO8-6"/>\r
515 $ git checkout pu &amp;&amp; git reset --hard next <co id="CO8-7"/>\r
516 $ git merge topic/one topic/two &amp;&amp; git merge hold/linus <co id="CO8-8"/>\r
517 $ git checkout maint\r
518 $ git cherry-pick master~4 <co id="CO8-9"/>\r
519 $ compile/test\r
520 $ git tag -s -m "GIT 0.99.9x" v0.99.9x <co id="CO8-10"/>\r
521 $ git fetch ko &amp;&amp; git show-branch master maint 'tags/ko-*' <co id="CO8-11"/>\r
522 $ git push ko <co id="CO8-12"/>\r
523 $ git push ko v0.99.9x <co id="CO8-13"/></literallayout>\r
524 <calloutlist>\r
525 <callout arearefs="CO8-1">\r
526 <simpara>\r
527 see what I was in the middle of doing, if any.\r
528 </simpara>\r
529 </callout>\r
530 <callout arearefs="CO8-2">\r
531 <simpara>\r
532 see what topic branches I have and think about how ready\r
533 they are.\r
534 </simpara>\r
535 </callout>\r
536 <callout arearefs="CO8-3">\r
537 <simpara>\r
538 read mails, save ones that are applicable, and save others\r
539 that are not quite ready.\r
540 </simpara>\r
541 </callout>\r
542 <callout arearefs="CO8-4">\r
543 <simpara>\r
544 apply them, interactively, with my sign-offs.\r
545 </simpara>\r
546 </callout>\r
547 <callout arearefs="CO8-5">\r
548 <simpara>\r
549 create topic branch as needed and apply, again with my\r
550 sign-offs.\r
551 </simpara>\r
552 </callout>\r
553 <callout arearefs="CO8-6">\r
554 <simpara>\r
555 rebase internal topic branch that has not been merged to the\r
556 master, nor exposed as a part of a stable branch.\r
557 </simpara>\r
558 </callout>\r
559 <callout arearefs="CO8-7">\r
560 <simpara>\r
561 restart <literal>pu</literal> every time from the next.\r
562 </simpara>\r
563 </callout>\r
564 <callout arearefs="CO8-8">\r
565 <simpara>\r
566 and bundle topic branches still cooking.\r
567 </simpara>\r
568 </callout>\r
569 <callout arearefs="CO8-9">\r
570 <simpara>\r
571 backport a critical fix.\r
572 </simpara>\r
573 </callout>\r
574 <callout arearefs="CO8-10">\r
575 <simpara>\r
576 create a signed tag.\r
577 </simpara>\r
578 </callout>\r
579 <callout arearefs="CO8-11">\r
580 <simpara>\r
581 make sure I did not accidentally rewind master beyond what I\r
582 already pushed out.  <literal>ko</literal> shorthand points at the repository I have\r
583 at kernel.org, and looks like this:\r
584 </simpara>\r
585 <literallayout>$ cat .git/remotes/ko\r
586 URL: kernel.org:/pub/scm/git/git.git\r
587 Pull: master:refs/tags/ko-master\r
588 Pull: next:refs/tags/ko-next\r
589 Pull: maint:refs/tags/ko-maint\r
590 Push: master\r
591 Push: next\r
592 Push: +pu\r
593 Push: maint</literallayout>\r
594 <simpara>In the output from <literal>git show-branch</literal>, <literal>master</literal> should have\r
595 everything <literal>ko-master</literal> has, and <literal>next</literal> should have\r
596 everything <literal>ko-next</literal> has.</simpara>\r
597 </callout>\r
598 <callout arearefs="CO8-12">\r
599 <simpara>\r
600 push out the bleeding edge.\r
601 </simpara>\r
602 </callout>\r
603 <callout arearefs="CO8-13">\r
604 <simpara>\r
605 push the tag out, too.\r
606 </simpara>\r
607 </callout>\r
608 </calloutlist>\r
609 </listitem>\r
610 </varlistentry>\r
611 </variablelist>\r
612 </simplesect>\r
613 </simplesect>\r
614 <simplesect id="_repository_administration_anchor_id_repository_administration_xreflabel_repository_administration">\r
615 <title>Repository Administration<anchor id="Repository Administration" xreflabel="[Repository Administration]"/></title>\r
616 <simpara>A repository administrator uses the following tools to set up\r
617 and maintain access to the repository by developers.</simpara>\r
618 <itemizedlist>\r
619 <listitem>\r
620 <simpara>\r
621 <xref linkend="git-daemon(1)"/> to allow anonymous download from\r
622     repository.\r
623 </simpara>\r
624 </listitem>\r
625 <listitem>\r
626 <simpara>\r
627 <xref linkend="git-shell(1)"/> can be used as a <emphasis>restricted login shell</emphasis>\r
628     for shared central repository users.\r
629 </simpara>\r
630 </listitem>\r
631 </itemizedlist>\r
632 <simpara><ulink url="howto/update-hook-example.txt">update hook howto</ulink> has a good\r
633 example of managing a shared central repository.</simpara>\r
634 <simplesect id="_examples_5">\r
635 <title>Examples</title>\r
636 <variablelist>\r
637 <varlistentry>\r
638 <term>\r
639 We assume the following in /etc/services\r
640 </term>\r
641 <listitem>\r
642 <literallayout>$ grep 9418 /etc/services\r
643 git             9418/tcp                # Git Version Control System</literallayout>\r
644 </listitem>\r
645 </varlistentry>\r
646 <varlistentry>\r
647 <term>\r
648 Run git-daemon to serve /pub/scm from inetd.\r
649 </term>\r
650 <listitem>\r
651 <literallayout>$ grep git /etc/inetd.conf\r
652 git     stream  tcp     nowait  nobody \\r
653   /usr/bin/git-daemon git-daemon --inetd --export-all /pub/scm</literallayout>\r
654 <simpara>The actual configuration line should be on one line.</simpara>\r
655 </listitem>\r
656 </varlistentry>\r
657 <varlistentry>\r
658 <term>\r
659 Run git-daemon to serve /pub/scm from xinetd.\r
660 </term>\r
661 <listitem>\r
662 <literallayout>$ cat /etc/xinetd.d/git-daemon\r
663 # default: off\r
664 # description: The git server offers access to git repositories\r
665 service git\r
666 {\r
667         disable = no\r
668         type            = UNLISTED\r
669         port            = 9418\r
670         socket_type     = stream\r
671         wait            = no\r
672         user            = nobody\r
673         server          = /usr/bin/git-daemon\r
674         server_args     = --inetd --export-all --base-path=/pub/scm\r
675         log_on_failure  += USERID\r
676 }</literallayout>\r
677 <simpara>Check your xinetd(8) documentation and setup, this is from a Fedora system.\r
678 Others might be different.</simpara>\r
679 </listitem>\r
680 </varlistentry>\r
681 <varlistentry>\r
682 <term>\r
683 Give push/pull only access to developers.\r
684 </term>\r
685 <listitem>\r
686 <literallayout>$ grep git /etc/passwd <co id="CO9-1"/>\r
687 alice:x:1000:1000::/home/alice:/usr/bin/git-shell\r
688 bob:x:1001:1001::/home/bob:/usr/bin/git-shell\r
689 cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell\r
690 david:x:1003:1003::/home/david:/usr/bin/git-shell\r
691 $ grep git /etc/shells <co id="CO9-2"/>\r
692 /usr/bin/git-shell</literallayout>\r
693 <calloutlist>\r
694 <callout arearefs="CO9-1">\r
695 <simpara>\r
696 log-in shell is set to /usr/bin/git-shell, which does not\r
697 allow anything but <literal>git push</literal> and <literal>git pull</literal>.  The users should\r
698 get an ssh access to the machine.\r
699 </simpara>\r
700 </callout>\r
701 <callout arearefs="CO9-2">\r
702 <simpara>\r
703 in many distributions /etc/shells needs to list what is used\r
704 as the login shell.\r
705 </simpara>\r
706 </callout>\r
707 </calloutlist>\r
708 </listitem>\r
709 </varlistentry>\r
710 <varlistentry>\r
711 <term>\r
712 CVS-style shared repository.\r
713 </term>\r
714 <listitem>\r
715 <literallayout>$ grep git /etc/group <co id="CO10-1"/>\r
716 git:x:9418:alice,bob,cindy,david\r
717 $ cd /home/devo.git\r
718 $ ls -l <co id="CO10-2"/>\r
719   lrwxrwxrwx   1 david git    17 Dec  4 22:40 HEAD -&gt; refs/heads/master\r
720   drwxrwsr-x   2 david git  4096 Dec  4 22:40 branches\r
721   -rw-rw-r--   1 david git    84 Dec  4 22:40 config\r
722   -rw-rw-r--   1 david git    58 Dec  4 22:40 description\r
723   drwxrwsr-x   2 david git  4096 Dec  4 22:40 hooks\r
724   -rw-rw-r--   1 david git 37504 Dec  4 22:40 index\r
725   drwxrwsr-x   2 david git  4096 Dec  4 22:40 info\r
726   drwxrwsr-x   4 david git  4096 Dec  4 22:40 objects\r
727   drwxrwsr-x   4 david git  4096 Nov  7 14:58 refs\r
728   drwxrwsr-x   2 david git  4096 Dec  4 22:40 remotes\r
729 $ ls -l hooks/update <co id="CO10-3"/>\r
730   -r-xr-xr-x   1 david git  3536 Dec  4 22:40 update\r
731 $ cat info/allowed-users <co id="CO10-4"/>\r
732 refs/heads/master       alice\|cindy\r
733 refs/heads/doc-update   bob\r
734 refs/tags/v[0-9]*       david</literallayout>\r
735 <calloutlist>\r
736 <callout arearefs="CO10-1">\r
737 <simpara>\r
738 place the developers into the same git group.\r
739 </simpara>\r
740 </callout>\r
741 <callout arearefs="CO10-2">\r
742 <simpara>\r
743 and make the shared repository writable by the group.\r
744 </simpara>\r
745 </callout>\r
746 <callout arearefs="CO10-3">\r
747 <simpara>\r
748 use update-hook example by Carl from Documentation/howto/\r
749 for branch policy control.\r
750 </simpara>\r
751 </callout>\r
752 <callout arearefs="CO10-4">\r
753 <simpara>\r
754 alice and cindy can push into master, only bob can push into doc-update.\r
755 david is the release manager and is the only person who can\r
756 create and push version tags.\r
757 </simpara>\r
758 </callout>\r
759 </calloutlist>\r
760 </listitem>\r
761 </varlistentry>\r
762 <varlistentry>\r
763 <term>\r
764 HTTP server to support dumb protocol transfer.\r
765 </term>\r
766 <listitem>\r
767 <literallayout>dev$ git update-server-info <co id="CO11-1"/>\r
768 dev$ ftp user@isp.example.com <co id="CO11-2"/>\r
769 ftp&gt; cp -r .git /home/user/myproject.git</literallayout>\r
770 <calloutlist>\r
771 <callout arearefs="CO11-1">\r
772 <simpara>\r
773 make sure your info/refs and objects/info/packs are up-to-date\r
774 </simpara>\r
775 </callout>\r
776 <callout arearefs="CO11-2">\r
777 <simpara>\r
778 upload to public HTTP server hosted by your ISP.\r
779 </simpara>\r
780 </callout>\r
781 </calloutlist>\r
782 </listitem>\r
783 </varlistentry>\r
784 </variablelist>\r
785 </simplesect>\r
786 </simplesect>\r
787 </article>\r