blob: 147844db30feb3f8c8d3952246121bd7012529c0 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamanoc8d88c22006-04-29 07:02:016<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229/* Workarounds for IE6's broken and incomplete CSS2. */
230
231div.sidebar-content {
232 background: #ffffee;
233 border: 1px solid silver;
234 padding: 0.5em;
235}
236div.sidebar-title, div.image-title {
237 font-family: sans-serif;
238 font-weight: bold;
239 margin-top: 0.0em;
240 margin-bottom: 0.5em;
241}
242
243div.listingblock div.content {
244 border: 1px solid silver;
245 background: #f4f4f4;
246 padding: 0.5em;
247}
248
249div.quoteblock-content {
250 padding-left: 2.0em;
251}
252
253div.exampleblock-content {
254 border-left: 2px solid silver;
255 padding-left: 0.5em;
256}
257</style>
258<title>Everyday GIT With 20 Commands Or So</title>
259</head>
260<body>
261<div id="header">
262<h1>Everyday GIT With 20 Commands Or So</h1>
263</div>
264<div id="preamble">
265<div class="sectionbody">
Junio C Hamano29f14312006-10-26 08:47:29266<p><a href="#Basic Repository">[Basic Repository]</a> commands are needed by people who have a
Junio C Hamano1a4e8412005-12-27 08:17:23267repository --- that is everybody, because every working tree of
268git is a repository.</p>
269<p>In addition, <a href="#Individual Developer (Standalone)">[Individual Developer (Standalone)]</a> commands are
270essential for anybody who makes a commit, even for somebody who
271works alone.</p>
272<p>If you work with other people, you will need commands listed in
Junio C Hamano29f14312006-10-26 08:47:29273the <a href="#Individual Developer (Participant)">[Individual Developer (Participant)]</a> section as well.</p>
274<p>People who play the <a href="#Integrator">[Integrator]</a> role need to learn some more
Junio C Hamano1a4e8412005-12-27 08:17:23275commands in addition to the above.</p>
276<p><a href="#Repository Administration">[Repository Administration]</a> commands are for system
Junio C Hamano29f14312006-10-26 08:47:29277administrators who are responsible for the care and feeding
278of git repositories.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23279</div>
280</div>
281<h2>Basic Repository<a id="Basic Repository"></a></h2>
282<div class="sectionbody">
Junio C Hamano29f14312006-10-26 08:47:29283<p>Everybody uses these commands to maintain git repositories.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23284<ul>
285<li>
286<p>
Junio C Hamanofc4d38c2007-01-08 06:53:32287<a href="git-init.html">git-init(1)</a> or <a href="git-clone.html">git-clone(1)</a> to create a
Junio C Hamano1a4e8412005-12-27 08:17:23288 new repository.
289</p>
290</li>
291<li>
292<p>
Junio C Hamano7ad22dc2007-01-29 02:55:48293<a href="git-fsck.html">git-fsck(1)</a> to check the repository for errors.
Junio C Hamano1a4e8412005-12-27 08:17:23294</p>
295</li>
296<li>
297<p>
Junio C Hamano52299462006-12-28 00:59:38298<a href="git-gc.html">git-gc(1)</a> to do common housekeeping tasks such as
299 repack and prune.
300</p>
301</li>
Junio C Hamano1a4e8412005-12-27 08:17:23302</ul>
303<h3>Examples</h3>
304<dl>
305<dt>
306Check health and remove cruft.
307</dt>
308<dd>
309<div class="listingblock">
310<div class="content">
Junio C Hamano7ad22dc2007-01-29 02:55:48311<pre><tt>$ git fsck <b>(1)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23312$ git count-objects <b>(2)</b>
Junio C Hamanoe27cbd22007-12-21 17:57:33313$ git gc <b>(3)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23314</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01315<ol>
316<li>
317<p>
Junio C Hamano74640642006-12-27 10:59:55318running without <tt>--full</tt> is usually cheap and assures the
Junio C Hamanoc8d88c22006-04-29 07:02:01319repository health reasonably well.
320</p>
321</li>
322<li>
323<p>
324check how many loose objects there are and how much
Junio C Hamanobb8fb052006-05-30 07:21:12325disk space is wasted by not repacking.
Junio C Hamanoc8d88c22006-04-29 07:02:01326</p>
327</li>
328<li>
329<p>
Junio C Hamanoa9aee782008-04-23 16:09:20330repacks the local repository and performs other housekeeping tasks.
Junio C Hamanoc8d88c22006-04-29 07:02:01331</p>
332</li>
333</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23334</dd>
335<dt>
336Repack a small project into single pack.
337</dt>
338<dd>
339<div class="listingblock">
340<div class="content">
Junio C Hamanoa9aee782008-04-23 16:09:20341<pre><tt>$ git gc <b>(1)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23342</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01343<ol>
344<li>
345<p>
Junio C Hamano29f14312006-10-26 08:47:29346pack all the objects reachable from the refs into one pack,
347then remove the other packs.
Junio C Hamanoc8d88c22006-04-29 07:02:01348</p>
349</li>
350</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23351</dd>
352</dl>
353</div>
354<h2>Individual Developer (Standalone)<a id="Individual Developer (Standalone)"></a></h2>
355<div class="sectionbody">
356<p>A standalone individual developer does not exchange patches with
Junio C Hamanobb8fb052006-05-30 07:21:12357other people, and works alone in a single repository, using the
Junio C Hamano1a4e8412005-12-27 08:17:23358following commands.</p>
359<ul>
360<li>
361<p>
362<a href="git-show-branch.html">git-show-branch(1)</a> to see where you are.
363</p>
364</li>
365<li>
366<p>
367<a href="git-log.html">git-log(1)</a> to see what happened.
368</p>
369</li>
370<li>
371<p>
Junio C Hamano1a4e8412005-12-27 08:17:23372<a href="git-checkout.html">git-checkout(1)</a> and <a href="git-branch.html">git-branch(1)</a> to switch
373 branches.
374</p>
375</li>
376<li>
377<p>
Junio C Hamano74640642006-12-27 10:59:55378<a href="git-add.html">git-add(1)</a> to manage the index file.
Junio C Hamano1a4e8412005-12-27 08:17:23379</p>
380</li>
381<li>
382<p>
383<a href="git-diff.html">git-diff(1)</a> and <a href="git-status.html">git-status(1)</a> to see what
384 you are in the middle of doing.
385</p>
386</li>
387<li>
388<p>
389<a href="git-commit.html">git-commit(1)</a> to advance the current branch.
390</p>
391</li>
392<li>
393<p>
394<a href="git-reset.html">git-reset(1)</a> and <a href="git-checkout.html">git-checkout(1)</a> (with
395 pathname parameters) to undo changes.
396</p>
397</li>
398<li>
399<p>
Junio C Hamano74640642006-12-27 10:59:55400<a href="git-merge.html">git-merge(1)</a> to merge between local branches.
Junio C Hamano1a4e8412005-12-27 08:17:23401</p>
402</li>
403<li>
404<p>
405<a href="git-rebase.html">git-rebase(1)</a> to maintain topic branches.
406</p>
407</li>
408<li>
409<p>
410<a href="git-tag.html">git-tag(1)</a> to mark known point.
411</p>
412</li>
413</ul>
414<h3>Examples</h3>
Junio C Hamano74640642006-12-27 10:59:55415<dl>
416<dt>
417Use a tarball as a starting point for a new repository.
418</dt>
419<dd>
Junio C Hamano1a4e8412005-12-27 08:17:23420<div class="listingblock">
421<div class="content">
422<pre><tt>$ tar zxf frotz.tar.gz
423$ cd frotz
Junio C Hamanofc4d38c2007-01-08 06:53:32424$ git-init
Junio C Hamano1a4e8412005-12-27 08:17:23425$ git add . <b>(1)</b>
Junio C Hamano7ae0ab22007-11-03 02:46:46426$ git commit -m "import of frotz source tree."
Junio C Hamanoc8d88c22006-04-29 07:02:01427$ git tag v2.43 <b>(2)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23428</div></div>
Junio C Hamano74640642006-12-27 10:59:55429<ol>
430<li>
431<p>
432add everything under the current directory.
433</p>
434</li>
435<li>
436<p>
437make a lightweight, unannotated tag.
438</p>
439</li>
440</ol>
441</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23442<dt>
443Create a topic branch and develop.
444</dt>
445<dd>
446<div class="listingblock">
447<div class="content">
448<pre><tt>$ git checkout -b alsa-audio <b>(1)</b>
449$ edit/compile/test
450$ git checkout -- curses/ux_audio_oss.c <b>(2)</b>
451$ git add curses/ux_audio_alsa.c <b>(3)</b>
452$ edit/compile/test
Junio C Hamano74640642006-12-27 10:59:55453$ git diff HEAD <b>(4)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23454$ git commit -a -s <b>(5)</b>
455$ edit/compile/test
456$ git reset --soft HEAD^ <b>(6)</b>
457$ edit/compile/test
458$ git diff ORIG_HEAD <b>(7)</b>
459$ git commit -a -c ORIG_HEAD <b>(8)</b>
460$ git checkout master <b>(9)</b>
Junio C Hamano74640642006-12-27 10:59:55461$ git merge alsa-audio <b>(10)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23462$ git log --since='3 days ago' <b>(11)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:01463$ git log v2.43.. curses/ <b>(12)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23464</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01465<ol>
466<li>
467<p>
468create a new topic branch.
469</p>
470</li>
471<li>
472<p>
Junio C Hamano74640642006-12-27 10:59:55473revert your botched changes in <tt>curses/ux_audio_oss.c</tt>.
Junio C Hamanoc8d88c22006-04-29 07:02:01474</p>
475</li>
476<li>
477<p>
478you need to tell git if you added a new file; removal and
Junio C Hamano74640642006-12-27 10:59:55479modification will be caught if you do <tt>git commit -a</tt> later.
Junio C Hamanoc8d88c22006-04-29 07:02:01480</p>
481</li>
482<li>
483<p>
484to see what changes you are committing.
485</p>
486</li>
487<li>
488<p>
489commit everything as you have tested, with your sign-off.
490</p>
491</li>
492<li>
493<p>
494take the last commit back, keeping what is in the working tree.
495</p>
496</li>
497<li>
498<p>
499look at the changes since the premature commit we took back.
500</p>
501</li>
502<li>
503<p>
504redo the commit undone in the previous step, using the message
505you originally wrote.
506</p>
507</li>
508<li>
509<p>
510switch to the master branch.
511</p>
512</li>
513<li>
514<p>
Junio C Hamanoedd2b0a2007-01-15 06:12:45515merge a topic branch into your master branch.
Junio C Hamanoc8d88c22006-04-29 07:02:01516</p>
517</li>
518<li>
519<p>
520review commit logs; other forms to limit output can be
Junio C Hamano74640642006-12-27 10:59:55521combined and include <tt>--max-count=10</tt> (show 10 commits),
522<tt>--until=2005-12-10</tt>, etc.
Junio C Hamanoc8d88c22006-04-29 07:02:01523</p>
524</li>
525<li>
526<p>
Junio C Hamano74640642006-12-27 10:59:55527view only the changes that touch what's in <tt>curses/</tt>
528directory, since <tt>v2.43</tt> tag.
Junio C Hamanoc8d88c22006-04-29 07:02:01529</p>
530</li>
531</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23532</dd>
533</dl>
534</div>
535<h2>Individual Developer (Participant)<a id="Individual Developer (Participant)"></a></h2>
536<div class="sectionbody">
537<p>A developer working as a participant in a group project needs to
538learn how to communicate with others, and uses these commands in
539addition to the ones needed by a standalone developer.</p>
540<ul>
541<li>
542<p>
543<a href="git-clone.html">git-clone(1)</a> from the upstream to prime your local
544 repository.
545</p>
546</li>
547<li>
548<p>
549<a href="git-pull.html">git-pull(1)</a> and <a href="git-fetch.html">git-fetch(1)</a> from "origin"
550 to keep up-to-date with the upstream.
551</p>
552</li>
553<li>
554<p>
555<a href="git-push.html">git-push(1)</a> to shared repository, if you adopt CVS
556 style shared repository workflow.
557</p>
558</li>
559<li>
560<p>
561<a href="git-format-patch.html">git-format-patch(1)</a> to prepare e-mail submission, if
562 you adopt Linux kernel-style public forum workflow.
563</p>
564</li>
565</ul>
566<h3>Examples</h3>
567<dl>
568<dt>
569Clone the upstream and work on it. Feed changes to upstream.
570</dt>
571<dd>
572<div class="listingblock">
573<div class="content">
574<pre><tt>$ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6
575$ cd my2.6
576$ edit/compile/test; git commit -a -s <b>(1)</b>
577$ git format-patch origin <b>(2)</b>
578$ git pull <b>(3)</b>
Junio C Hamano29f14312006-10-26 08:47:29579$ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 <b>(4)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23580$ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <b>(5)</b>
581$ git reset --hard ORIG_HEAD <b>(6)</b>
Junio C Hamanoa9aee782008-04-23 16:09:20582$ git gc <b>(7)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:01583$ git fetch --tags <b>(8)</b></tt></pre>
584</div></div>
585<ol>
586<li>
587<p>
588repeat as needed.
589</p>
590</li>
591<li>
592<p>
593extract patches from your branch for e-mail submission.
594</p>
595</li>
596<li>
597<p>
Junio C Hamano74640642006-12-27 10:59:55598<tt>git pull</tt> fetches from <tt>origin</tt> by default and merges into the
Junio C Hamano1a4e8412005-12-27 08:17:23599current branch.
Junio C Hamanoc8d88c22006-04-29 07:02:01600</p>
601</li>
602<li>
603<p>
604immediately after pulling, look at the changes done upstream
Junio C Hamano1a4e8412005-12-27 08:17:23605since last time we checked, only in the
606area we are interested in.
Junio C Hamanoc8d88c22006-04-29 07:02:01607</p>
608</li>
609<li>
610<p>
611fetch from a specific branch from a specific repository and merge.
612</p>
613</li>
614<li>
615<p>
616revert the pull.
617</p>
618</li>
619<li>
620<p>
621garbage collect leftover objects from reverted pull.
622</p>
623</li>
624<li>
625<p>
Junio C Hamano74640642006-12-27 10:59:55626from time to time, obtain official tags from the <tt>origin</tt>
627and store them under <tt>.git/refs/tags/</tt>.
Junio C Hamanoc8d88c22006-04-29 07:02:01628</p>
629</li>
630</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23631</dd>
632<dt>
633Push into another repository.
634</dt>
635<dd>
636<div class="listingblock">
637<div class="content">
Junio C Hamano74640642006-12-27 10:59:55638<pre><tt>satellite$ git clone mothership:frotz frotz <b>(1)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23639satellite$ cd frotz
Junio C Hamano7ad22dc2007-01-29 02:55:48640satellite$ git config --get-regexp '^(remote|branch)\.' <b>(2)</b>
Junio C Hamano74640642006-12-27 10:59:55641remote.origin.url mothership:frotz
642remote.origin.fetch refs/heads/*:refs/remotes/origin/*
643branch.master.remote origin
644branch.master.merge refs/heads/master
Junio C Hamano7ad22dc2007-01-29 02:55:48645satellite$ git config remote.origin.push \
Junio C Hamano74640642006-12-27 10:59:55646 master:refs/remotes/satellite/master <b>(3)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23647satellite$ edit/compile/test/commit
648satellite$ git push origin <b>(4)</b>
649
650mothership$ cd frotz
651mothership$ git checkout master
Junio C Hamano74640642006-12-27 10:59:55652mothership$ git merge satellite/master <b>(5)</b></tt></pre>
Junio C Hamanoc8d88c22006-04-29 07:02:01653</div></div>
654<ol>
655<li>
656<p>
657mothership machine has a frotz repository under your home
Junio C Hamano1a4e8412005-12-27 08:17:23658directory; clone from it to start a repository on the satellite
659machine.
Junio C Hamanoc8d88c22006-04-29 07:02:01660</p>
661</li>
662<li>
663<p>
Junio C Hamano74640642006-12-27 10:59:55664clone sets these configuration variables by default.
665It arranges <tt>git pull</tt> to fetch and store the branches of mothership
666machine to local <tt>remotes/origin/*</tt> tracking branches.
Junio C Hamanoc8d88c22006-04-29 07:02:01667</p>
668</li>
669<li>
670<p>
Junio C Hamano74640642006-12-27 10:59:55671arrange <tt>git push</tt> to push local <tt>master</tt> branch to
672<tt>remotes/satellite/master</tt> branch of the mothership machine.
Junio C Hamanoc8d88c22006-04-29 07:02:01673</p>
674</li>
675<li>
676<p>
Junio C Hamano74640642006-12-27 10:59:55677push will stash our work away on <tt>remotes/satellite/master</tt>
678tracking branch on the mothership machine. You could use this as
679a back-up method.
Junio C Hamanoc8d88c22006-04-29 07:02:01680</p>
681</li>
682<li>
683<p>
684on mothership machine, merge the work done on the satellite
685machine into the master branch.
686</p>
687</li>
688</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23689</dd>
690<dt>
691Branch off of a specific tag.
692</dt>
693<dd>
694<div class="listingblock">
695<div class="content">
696<pre><tt>$ git checkout -b private2.6.14 v2.6.14 <b>(1)</b>
697$ edit/compile/test; git commit -a
698$ git checkout master
699$ git format-patch -k -m --stdout v2.6.14..private2.6.14 |
Junio C Hamanoc8d88c22006-04-29 07:02:01700 git am -3 -k <b>(2)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23701</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01702<ol>
703<li>
704<p>
705create a private branch based on a well known (but somewhat behind)
706tag.
707</p>
708</li>
709<li>
710<p>
Junio C Hamano74640642006-12-27 10:59:55711forward port all changes in <tt>private2.6.14</tt> branch to <tt>master</tt> branch
Junio C Hamanoc8d88c22006-04-29 07:02:01712without a formal "merging".
713</p>
714</li>
715</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23716</dd>
717</dl>
718</div>
719<h2>Integrator<a id="Integrator"></a></h2>
720<div class="sectionbody">
721<p>A fairly central person acting as the integrator in a group
722project receives changes made by others, reviews and integrates
723them and publishes the result for others to use, using these
724commands in addition to the ones needed by participants.</p>
725<ul>
726<li>
727<p>
728<a href="git-am.html">git-am(1)</a> to apply patches e-mailed in from your
729 contributors.
730</p>
731</li>
732<li>
733<p>
734<a href="git-pull.html">git-pull(1)</a> to merge from your trusted lieutenants.
735</p>
736</li>
737<li>
738<p>
739<a href="git-format-patch.html">git-format-patch(1)</a> to prepare and send suggested
740 alternative to contributors.
741</p>
742</li>
743<li>
744<p>
745<a href="git-revert.html">git-revert(1)</a> to undo botched commits.
746</p>
747</li>
748<li>
749<p>
750<a href="git-push.html">git-push(1)</a> to publish the bleeding edge.
751</p>
752</li>
753</ul>
754<h3>Examples</h3>
755<dl>
756<dt>
757My typical GIT day.
758</dt>
759<dd>
760<div class="listingblock">
761<div class="content">
762<pre><tt>$ git status <b>(1)</b>
763$ git show-branch <b>(2)</b>
764$ mailx <b>(3)</b>
765&amp; s 2 3 4 5 ./+to-apply
766&amp; s 7 8 ./+hold-linus
767&amp; q
Junio C Hamano74640642006-12-27 10:59:55768$ git checkout -b topic/one master
Junio C Hamano1a4e8412005-12-27 08:17:23769$ git am -3 -i -s -u ./+to-apply <b>(4)</b>
770$ compile/test
771$ git checkout -b hold/linus &amp;&amp; git am -3 -i -s -u ./+hold-linus <b>(5)</b>
772$ git checkout topic/one &amp;&amp; git rebase master <b>(6)</b>
Junio C Hamano74640642006-12-27 10:59:55773$ git checkout pu &amp;&amp; git reset --hard next <b>(7)</b>
774$ git merge topic/one topic/two &amp;&amp; git merge hold/linus <b>(8)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23775$ git checkout maint
776$ git cherry-pick master~4 <b>(9)</b>
777$ compile/test
Junio C Hamano7ae0ab22007-11-03 02:46:46778$ git tag -s -m "GIT 0.99.9x" v0.99.9x <b>(10)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23779$ git fetch ko &amp;&amp; git show-branch master maint 'tags/ko-*' <b>(11)</b>
780$ git push ko <b>(12)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:01781$ git push ko v0.99.9x <b>(13)</b></tt></pre>
782</div></div>
783<ol>
784<li>
785<p>
786see what I was in the middle of doing, if any.
787</p>
788</li>
789<li>
790<p>
791see what topic branches I have and think about how ready
Junio C Hamano1a4e8412005-12-27 08:17:23792they are.
Junio C Hamanoc8d88c22006-04-29 07:02:01793</p>
794</li>
795<li>
796<p>
797read mails, save ones that are applicable, and save others
Junio C Hamano1a4e8412005-12-27 08:17:23798that are not quite ready.
Junio C Hamanoc8d88c22006-04-29 07:02:01799</p>
800</li>
801<li>
802<p>
803apply them, interactively, with my sign-offs.
804</p>
805</li>
806<li>
807<p>
808create topic branch as needed and apply, again with my
Junio C Hamano1a4e8412005-12-27 08:17:23809sign-offs.
Junio C Hamanoc8d88c22006-04-29 07:02:01810</p>
811</li>
812<li>
813<p>
814rebase internal topic branch that has not been merged to the
Junio C Hamano1a4e8412005-12-27 08:17:23815master, nor exposed as a part of a stable branch.
Junio C Hamanoc8d88c22006-04-29 07:02:01816</p>
817</li>
818<li>
819<p>
Junio C Hamano74640642006-12-27 10:59:55820restart <tt>pu</tt> every time from the next.
Junio C Hamanoc8d88c22006-04-29 07:02:01821</p>
822</li>
823<li>
824<p>
825and bundle topic branches still cooking.
826</p>
827</li>
828<li>
829<p>
830backport a critical fix.
831</p>
832</li>
833<li>
834<p>
835create a signed tag.
836</p>
837</li>
838<li>
839<p>
840make sure I did not accidentally rewind master beyond what I
Junio C Hamano74640642006-12-27 10:59:55841already pushed out. <tt>ko</tt> shorthand points at the repository I have
Junio C Hamano1a4e8412005-12-27 08:17:23842at kernel.org, and looks like this:
Junio C Hamanoc8d88c22006-04-29 07:02:01843</p>
Junio C Hamano7da87bb2006-06-06 01:23:49844<div class="listingblock">
845<div class="content">
846<pre><tt>$ cat .git/remotes/ko
847URL: kernel.org:/pub/scm/git/git.git
848Pull: master:refs/tags/ko-master
Junio C Hamano74640642006-12-27 10:59:55849Pull: next:refs/tags/ko-next
Junio C Hamano7da87bb2006-06-06 01:23:49850Pull: maint:refs/tags/ko-maint
851Push: master
Junio C Hamano74640642006-12-27 10:59:55852Push: next
Junio C Hamano7da87bb2006-06-06 01:23:49853Push: +pu
854Push: maint</tt></pre>
855</div></div>
Junio C Hamano74640642006-12-27 10:59:55856<p>In the output from <tt>git show-branch</tt>, <tt>master</tt> should have
857everything <tt>ko-master</tt> has, and <tt>next</tt> should have
858everything <tt>ko-next</tt> has.</p>
Junio C Hamanoc8d88c22006-04-29 07:02:01859</li>
860<li>
861<p>
862push out the bleeding edge.
863</p>
864</li>
865<li>
866<p>
867push the tag out, too.
868</p>
869</li>
870</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23871</dd>
872</dl>
873</div>
874<h2>Repository Administration<a id="Repository Administration"></a></h2>
875<div class="sectionbody">
876<p>A repository administrator uses the following tools to set up
877and maintain access to the repository by developers.</p>
878<ul>
879<li>
880<p>
881<a href="git-daemon.html">git-daemon(1)</a> to allow anonymous download from
882 repository.
883</p>
884</li>
885<li>
886<p>
887<a href="git-shell.html">git-shell(1)</a> can be used as a <em>restricted login shell</em>
888 for shared central repository users.
889</p>
890</li>
891</ul>
892<p><a href="howto/update-hook-example.txt">update hook howto</a> has a good
893example of managing a shared central repository.</p>
894<h3>Examples</h3>
895<dl>
896<dt>
Junio C Hamanoa053d542006-10-27 09:29:13897We assume the following in /etc/services
898</dt>
899<dd>
900<div class="listingblock">
901<div class="content">
902<pre><tt>$ grep 9418 /etc/services
903git 9418/tcp # Git Version Control System</tt></pre>
904</div></div>
905</dd>
906<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23907Run git-daemon to serve /pub/scm from inetd.
908</dt>
909<dd>
910<div class="listingblock">
911<div class="content">
Junio C Hamanobb8fb052006-05-30 07:21:12912<pre><tt>$ grep git /etc/inetd.conf
Junio C Hamano1a4e8412005-12-27 08:17:23913git stream tcp nowait nobody \
Junio C Hamano29f14312006-10-26 08:47:29914 /usr/bin/git-daemon git-daemon --inetd --export-all /pub/scm</tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23915</div></div>
916<p>The actual configuration line should be on one line.</p>
917</dd>
918<dt>
Junio C Hamano7da87bb2006-06-06 01:23:49919Run git-daemon to serve /pub/scm from xinetd.
920</dt>
921<dd>
922<div class="listingblock">
923<div class="content">
924<pre><tt>$ cat /etc/xinetd.d/git-daemon
925# default: off
926# description: The git server offers access to git repositories
927service git
928{
929 disable = no
930 type = UNLISTED
931 port = 9418
932 socket_type = stream
933 wait = no
934 user = nobody
935 server = /usr/bin/git-daemon
Junio C Hamano29f14312006-10-26 08:47:29936 server_args = --inetd --export-all --base-path=/pub/scm
Junio C Hamano7da87bb2006-06-06 01:23:49937 log_on_failure += USERID
938}</tt></pre>
939</div></div>
940<p>Check your xinetd(8) documentation and setup, this is from a Fedora system.
941Others might be different.</p>
942</dd>
943<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23944Give push/pull only access to developers.
945</dt>
946<dd>
947<div class="listingblock">
948<div class="content">
949<pre><tt>$ grep git /etc/passwd <b>(1)</b>
950alice:x:1000:1000::/home/alice:/usr/bin/git-shell
951bob:x:1001:1001::/home/bob:/usr/bin/git-shell
952cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell
953david:x:1003:1003::/home/david:/usr/bin/git-shell
954$ grep git /etc/shells <b>(2)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:01955/usr/bin/git-shell</tt></pre>
956</div></div>
957<ol>
958<li>
959<p>
960log-in shell is set to /usr/bin/git-shell, which does not
Junio C Hamano74640642006-12-27 10:59:55961allow anything but <tt>git push</tt> and <tt>git pull</tt>. The users should
Junio C Hamano1a4e8412005-12-27 08:17:23962get an ssh access to the machine.
Junio C Hamanoc8d88c22006-04-29 07:02:01963</p>
964</li>
965<li>
966<p>
967in many distributions /etc/shells needs to list what is used
968as the login shell.
969</p>
970</li>
971</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23972</dd>
973<dt>
974CVS-style shared repository.
975</dt>
976<dd>
977<div class="listingblock">
978<div class="content">
979<pre><tt>$ grep git /etc/group <b>(1)</b>
980git:x:9418:alice,bob,cindy,david
981$ cd /home/devo.git
982$ ls -l <b>(2)</b>
983 lrwxrwxrwx 1 david git 17 Dec 4 22:40 HEAD -&gt; refs/heads/master
984 drwxrwsr-x 2 david git 4096 Dec 4 22:40 branches
985 -rw-rw-r-- 1 david git 84 Dec 4 22:40 config
986 -rw-rw-r-- 1 david git 58 Dec 4 22:40 description
987 drwxrwsr-x 2 david git 4096 Dec 4 22:40 hooks
988 -rw-rw-r-- 1 david git 37504 Dec 4 22:40 index
989 drwxrwsr-x 2 david git 4096 Dec 4 22:40 info
990 drwxrwsr-x 4 david git 4096 Dec 4 22:40 objects
991 drwxrwsr-x 4 david git 4096 Nov 7 14:58 refs
992 drwxrwsr-x 2 david git 4096 Dec 4 22:40 remotes
993$ ls -l hooks/update <b>(3)</b>
994 -r-xr-xr-x 1 david git 3536 Dec 4 22:40 update
995$ cat info/allowed-users <b>(4)</b>
996refs/heads/master alice\|cindy
997refs/heads/doc-update bob
Junio C Hamanoc8d88c22006-04-29 07:02:01998refs/tags/v[0-9]* david</tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23999</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:011000<ol>
1001<li>
1002<p>
1003place the developers into the same git group.
1004</p>
1005</li>
1006<li>
1007<p>
1008and make the shared repository writable by the group.
1009</p>
1010</li>
1011<li>
1012<p>
1013use update-hook example by Carl from Documentation/howto/
1014for branch policy control.
1015</p>
1016</li>
1017<li>
1018<p>
1019alice and cindy can push into master, only bob can push into doc-update.
1020david is the release manager and is the only person who can
1021create and push version tags.
1022</p>
1023</li>
1024</ol>
Junio C Hamano1a4e8412005-12-27 08:17:231025</dd>
1026<dt>
1027HTTP server to support dumb protocol transfer.
1028</dt>
1029<dd>
1030<div class="listingblock">
1031<div class="content">
1032<pre><tt>dev$ git update-server-info <b>(1)</b>
1033dev$ ftp user@isp.example.com <b>(2)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:011034ftp&gt; cp -r .git /home/user/myproject.git</tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:231035</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:011036<ol>
1037<li>
1038<p>
1039make sure your info/refs and objects/info/packs are up-to-date
1040</p>
1041</li>
1042<li>
1043<p>
1044upload to public HTTP server hosted by your ISP.
1045</p>
1046</li>
1047</ol>
Junio C Hamano1a4e8412005-12-27 08:17:231048</dd>
1049</dl>
1050</div>
1051<div id="footer">
1052<div id="footer-text">
Junio C Hamanoa9aee782008-04-23 16:09:201053Last updated 23-Apr-2008 16:08:38 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231054</div>
1055</div>
1056</body>
1057</html>