blob: 1648f09895eb6c265c2304503f4cc91ebebc9fcc [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 Hamano29f14312006-10-26 08:47:29298<a href="git-prune.html">git-prune(1)</a> to remove unused objects in the repository.
Junio C Hamano1a4e8412005-12-27 08:17:23299</p>
300</li>
301<li>
302<p>
303<a href="git-repack.html">git-repack(1)</a> to pack loose objects for efficiency.
304</p>
305</li>
Junio C Hamano52299462006-12-28 00:59:38306<li>
307<p>
308<a href="git-gc.html">git-gc(1)</a> to do common housekeeping tasks such as
309 repack and prune.
310</p>
311</li>
Junio C Hamano1a4e8412005-12-27 08:17:23312</ul>
313<h3>Examples</h3>
314<dl>
315<dt>
316Check health and remove cruft.
317</dt>
318<dd>
319<div class="listingblock">
320<div class="content">
Junio C Hamano7ad22dc2007-01-29 02:55:48321<pre><tt>$ git fsck <b>(1)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23322$ git count-objects <b>(2)</b>
323$ git repack <b>(3)</b>
Junio C Hamano52299462006-12-28 00:59:38324$ git gc <b>(4)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23325</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01326<ol>
327<li>
328<p>
Junio C Hamano74640642006-12-27 10:59:55329running without <tt>--full</tt> is usually cheap and assures the
Junio C Hamanoc8d88c22006-04-29 07:02:01330repository health reasonably well.
331</p>
332</li>
333<li>
334<p>
335check how many loose objects there are and how much
Junio C Hamanobb8fb052006-05-30 07:21:12336disk space is wasted by not repacking.
Junio C Hamanoc8d88c22006-04-29 07:02:01337</p>
338</li>
339<li>
340<p>
Junio C Hamano74640642006-12-27 10:59:55341without <tt>-a</tt> repacks incrementally. repacking every 4-5MB
Junio C Hamanoc8d88c22006-04-29 07:02:01342of loose objects accumulation may be a good rule of thumb.
343</p>
344</li>
345<li>
346<p>
Junio C Hamano52299462006-12-28 00:59:38347it is easier to use <tt>git gc</tt> than individual housekeeping commands
348such as <tt>prune</tt> and <tt>repack</tt>. This runs <tt>repack -a -d</tt>.
Junio C Hamanoc8d88c22006-04-29 07:02:01349</p>
350</li>
351</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23352</dd>
353<dt>
354Repack a small project into single pack.
355</dt>
356<dd>
357<div class="listingblock">
358<div class="content">
359<pre><tt>$ git repack -a -d <b>(1)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:01360$ git prune</tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23361</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01362<ol>
363<li>
364<p>
Junio C Hamano29f14312006-10-26 08:47:29365pack all the objects reachable from the refs into one pack,
366then remove the other packs.
Junio C Hamanoc8d88c22006-04-29 07:02:01367</p>
368</li>
369</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23370</dd>
371</dl>
372</div>
373<h2>Individual Developer (Standalone)<a id="Individual Developer (Standalone)"></a></h2>
374<div class="sectionbody">
375<p>A standalone individual developer does not exchange patches with
Junio C Hamanobb8fb052006-05-30 07:21:12376other people, and works alone in a single repository, using the
Junio C Hamano1a4e8412005-12-27 08:17:23377following commands.</p>
378<ul>
379<li>
380<p>
381<a href="git-show-branch.html">git-show-branch(1)</a> to see where you are.
382</p>
383</li>
384<li>
385<p>
386<a href="git-log.html">git-log(1)</a> to see what happened.
387</p>
388</li>
389<li>
390<p>
Junio C Hamano1a4e8412005-12-27 08:17:23391<a href="git-checkout.html">git-checkout(1)</a> and <a href="git-branch.html">git-branch(1)</a> to switch
392 branches.
393</p>
394</li>
395<li>
396<p>
Junio C Hamano74640642006-12-27 10:59:55397<a href="git-add.html">git-add(1)</a> to manage the index file.
Junio C Hamano1a4e8412005-12-27 08:17:23398</p>
399</li>
400<li>
401<p>
402<a href="git-diff.html">git-diff(1)</a> and <a href="git-status.html">git-status(1)</a> to see what
403 you are in the middle of doing.
404</p>
405</li>
406<li>
407<p>
408<a href="git-commit.html">git-commit(1)</a> to advance the current branch.
409</p>
410</li>
411<li>
412<p>
413<a href="git-reset.html">git-reset(1)</a> and <a href="git-checkout.html">git-checkout(1)</a> (with
414 pathname parameters) to undo changes.
415</p>
416</li>
417<li>
418<p>
Junio C Hamano74640642006-12-27 10:59:55419<a href="git-merge.html">git-merge(1)</a> to merge between local branches.
Junio C Hamano1a4e8412005-12-27 08:17:23420</p>
421</li>
422<li>
423<p>
424<a href="git-rebase.html">git-rebase(1)</a> to maintain topic branches.
425</p>
426</li>
427<li>
428<p>
429<a href="git-tag.html">git-tag(1)</a> to mark known point.
430</p>
431</li>
432</ul>
433<h3>Examples</h3>
Junio C Hamano74640642006-12-27 10:59:55434<dl>
435<dt>
436Use a tarball as a starting point for a new repository.
437</dt>
438<dd>
Junio C Hamano1a4e8412005-12-27 08:17:23439<div class="listingblock">
440<div class="content">
441<pre><tt>$ tar zxf frotz.tar.gz
442$ cd frotz
Junio C Hamanofc4d38c2007-01-08 06:53:32443$ git-init
Junio C Hamano1a4e8412005-12-27 08:17:23444$ git add . <b>(1)</b>
445$ git commit -m 'import of frotz source tree.'
Junio C Hamanoc8d88c22006-04-29 07:02:01446$ git tag v2.43 <b>(2)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23447</div></div>
Junio C Hamano74640642006-12-27 10:59:55448<ol>
449<li>
450<p>
451add everything under the current directory.
452</p>
453</li>
454<li>
455<p>
456make a lightweight, unannotated tag.
457</p>
458</li>
459</ol>
460</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23461<dt>
462Create a topic branch and develop.
463</dt>
464<dd>
465<div class="listingblock">
466<div class="content">
467<pre><tt>$ git checkout -b alsa-audio <b>(1)</b>
468$ edit/compile/test
469$ git checkout -- curses/ux_audio_oss.c <b>(2)</b>
470$ git add curses/ux_audio_alsa.c <b>(3)</b>
471$ edit/compile/test
Junio C Hamano74640642006-12-27 10:59:55472$ git diff HEAD <b>(4)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23473$ git commit -a -s <b>(5)</b>
474$ edit/compile/test
475$ git reset --soft HEAD^ <b>(6)</b>
476$ edit/compile/test
477$ git diff ORIG_HEAD <b>(7)</b>
478$ git commit -a -c ORIG_HEAD <b>(8)</b>
479$ git checkout master <b>(9)</b>
Junio C Hamano74640642006-12-27 10:59:55480$ git merge alsa-audio <b>(10)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23481$ git log --since='3 days ago' <b>(11)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:01482$ git log v2.43.. curses/ <b>(12)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23483</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01484<ol>
485<li>
486<p>
487create a new topic branch.
488</p>
489</li>
490<li>
491<p>
Junio C Hamano74640642006-12-27 10:59:55492revert your botched changes in <tt>curses/ux_audio_oss.c</tt>.
Junio C Hamanoc8d88c22006-04-29 07:02:01493</p>
494</li>
495<li>
496<p>
497you need to tell git if you added a new file; removal and
Junio C Hamano74640642006-12-27 10:59:55498modification will be caught if you do <tt>git commit -a</tt> later.
Junio C Hamanoc8d88c22006-04-29 07:02:01499</p>
500</li>
501<li>
502<p>
503to see what changes you are committing.
504</p>
505</li>
506<li>
507<p>
508commit everything as you have tested, with your sign-off.
509</p>
510</li>
511<li>
512<p>
513take the last commit back, keeping what is in the working tree.
514</p>
515</li>
516<li>
517<p>
518look at the changes since the premature commit we took back.
519</p>
520</li>
521<li>
522<p>
523redo the commit undone in the previous step, using the message
524you originally wrote.
525</p>
526</li>
527<li>
528<p>
529switch to the master branch.
530</p>
531</li>
532<li>
533<p>
Junio C Hamanoedd2b0a2007-01-15 06:12:45534merge a topic branch into your master branch.
Junio C Hamanoc8d88c22006-04-29 07:02:01535</p>
536</li>
537<li>
538<p>
539review commit logs; other forms to limit output can be
Junio C Hamano74640642006-12-27 10:59:55540combined and include <tt>--max-count=10</tt> (show 10 commits),
541<tt>--until=2005-12-10</tt>, etc.
Junio C Hamanoc8d88c22006-04-29 07:02:01542</p>
543</li>
544<li>
545<p>
Junio C Hamano74640642006-12-27 10:59:55546view only the changes that touch what's in <tt>curses/</tt>
547directory, since <tt>v2.43</tt> tag.
Junio C Hamanoc8d88c22006-04-29 07:02:01548</p>
549</li>
550</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23551</dd>
552</dl>
553</div>
554<h2>Individual Developer (Participant)<a id="Individual Developer (Participant)"></a></h2>
555<div class="sectionbody">
556<p>A developer working as a participant in a group project needs to
557learn how to communicate with others, and uses these commands in
558addition to the ones needed by a standalone developer.</p>
559<ul>
560<li>
561<p>
562<a href="git-clone.html">git-clone(1)</a> from the upstream to prime your local
563 repository.
564</p>
565</li>
566<li>
567<p>
568<a href="git-pull.html">git-pull(1)</a> and <a href="git-fetch.html">git-fetch(1)</a> from "origin"
569 to keep up-to-date with the upstream.
570</p>
571</li>
572<li>
573<p>
574<a href="git-push.html">git-push(1)</a> to shared repository, if you adopt CVS
575 style shared repository workflow.
576</p>
577</li>
578<li>
579<p>
580<a href="git-format-patch.html">git-format-patch(1)</a> to prepare e-mail submission, if
581 you adopt Linux kernel-style public forum workflow.
582</p>
583</li>
584</ul>
585<h3>Examples</h3>
586<dl>
587<dt>
588Clone the upstream and work on it. Feed changes to upstream.
589</dt>
590<dd>
591<div class="listingblock">
592<div class="content">
593<pre><tt>$ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6
594$ cd my2.6
595$ edit/compile/test; git commit -a -s <b>(1)</b>
596$ git format-patch origin <b>(2)</b>
597$ git pull <b>(3)</b>
Junio C Hamano29f14312006-10-26 08:47:29598$ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 <b>(4)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23599$ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <b>(5)</b>
600$ git reset --hard ORIG_HEAD <b>(6)</b>
601$ git prune <b>(7)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:01602$ git fetch --tags <b>(8)</b></tt></pre>
603</div></div>
604<ol>
605<li>
606<p>
607repeat as needed.
608</p>
609</li>
610<li>
611<p>
612extract patches from your branch for e-mail submission.
613</p>
614</li>
615<li>
616<p>
Junio C Hamano74640642006-12-27 10:59:55617<tt>git pull</tt> fetches from <tt>origin</tt> by default and merges into the
Junio C Hamano1a4e8412005-12-27 08:17:23618current branch.
Junio C Hamanoc8d88c22006-04-29 07:02:01619</p>
620</li>
621<li>
622<p>
623immediately after pulling, look at the changes done upstream
Junio C Hamano1a4e8412005-12-27 08:17:23624since last time we checked, only in the
625area we are interested in.
Junio C Hamanoc8d88c22006-04-29 07:02:01626</p>
627</li>
628<li>
629<p>
630fetch from a specific branch from a specific repository and merge.
631</p>
632</li>
633<li>
634<p>
635revert the pull.
636</p>
637</li>
638<li>
639<p>
640garbage collect leftover objects from reverted pull.
641</p>
642</li>
643<li>
644<p>
Junio C Hamano74640642006-12-27 10:59:55645from time to time, obtain official tags from the <tt>origin</tt>
646and store them under <tt>.git/refs/tags/</tt>.
Junio C Hamanoc8d88c22006-04-29 07:02:01647</p>
648</li>
649</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23650</dd>
651<dt>
652Push into another repository.
653</dt>
654<dd>
655<div class="listingblock">
656<div class="content">
Junio C Hamano74640642006-12-27 10:59:55657<pre><tt>satellite$ git clone mothership:frotz frotz <b>(1)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23658satellite$ cd frotz
Junio C Hamano7ad22dc2007-01-29 02:55:48659satellite$ git config --get-regexp '^(remote|branch)\.' <b>(2)</b>
Junio C Hamano74640642006-12-27 10:59:55660remote.origin.url mothership:frotz
661remote.origin.fetch refs/heads/*:refs/remotes/origin/*
662branch.master.remote origin
663branch.master.merge refs/heads/master
Junio C Hamano7ad22dc2007-01-29 02:55:48664satellite$ git config remote.origin.push \
Junio C Hamano74640642006-12-27 10:59:55665 master:refs/remotes/satellite/master <b>(3)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23666satellite$ edit/compile/test/commit
667satellite$ git push origin <b>(4)</b>
668
669mothership$ cd frotz
670mothership$ git checkout master
Junio C Hamano74640642006-12-27 10:59:55671mothership$ git merge satellite/master <b>(5)</b></tt></pre>
Junio C Hamanoc8d88c22006-04-29 07:02:01672</div></div>
673<ol>
674<li>
675<p>
676mothership machine has a frotz repository under your home
Junio C Hamano1a4e8412005-12-27 08:17:23677directory; clone from it to start a repository on the satellite
678machine.
Junio C Hamanoc8d88c22006-04-29 07:02:01679</p>
680</li>
681<li>
682<p>
Junio C Hamano74640642006-12-27 10:59:55683clone sets these configuration variables by default.
684It arranges <tt>git pull</tt> to fetch and store the branches of mothership
685machine to local <tt>remotes/origin/*</tt> tracking branches.
Junio C Hamanoc8d88c22006-04-29 07:02:01686</p>
687</li>
688<li>
689<p>
Junio C Hamano74640642006-12-27 10:59:55690arrange <tt>git push</tt> to push local <tt>master</tt> branch to
691<tt>remotes/satellite/master</tt> branch of the mothership machine.
Junio C Hamanoc8d88c22006-04-29 07:02:01692</p>
693</li>
694<li>
695<p>
Junio C Hamano74640642006-12-27 10:59:55696push will stash our work away on <tt>remotes/satellite/master</tt>
697tracking branch on the mothership machine. You could use this as
698a back-up method.
Junio C Hamanoc8d88c22006-04-29 07:02:01699</p>
700</li>
701<li>
702<p>
703on mothership machine, merge the work done on the satellite
704machine into the master branch.
705</p>
706</li>
707</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23708</dd>
709<dt>
710Branch off of a specific tag.
711</dt>
712<dd>
713<div class="listingblock">
714<div class="content">
715<pre><tt>$ git checkout -b private2.6.14 v2.6.14 <b>(1)</b>
716$ edit/compile/test; git commit -a
717$ git checkout master
718$ git format-patch -k -m --stdout v2.6.14..private2.6.14 |
Junio C Hamanoc8d88c22006-04-29 07:02:01719 git am -3 -k <b>(2)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23720</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01721<ol>
722<li>
723<p>
724create a private branch based on a well known (but somewhat behind)
725tag.
726</p>
727</li>
728<li>
729<p>
Junio C Hamano74640642006-12-27 10:59:55730forward port all changes in <tt>private2.6.14</tt> branch to <tt>master</tt> branch
Junio C Hamanoc8d88c22006-04-29 07:02:01731without a formal "merging".
732</p>
733</li>
734</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23735</dd>
736</dl>
737</div>
738<h2>Integrator<a id="Integrator"></a></h2>
739<div class="sectionbody">
740<p>A fairly central person acting as the integrator in a group
741project receives changes made by others, reviews and integrates
742them and publishes the result for others to use, using these
743commands in addition to the ones needed by participants.</p>
744<ul>
745<li>
746<p>
747<a href="git-am.html">git-am(1)</a> to apply patches e-mailed in from your
748 contributors.
749</p>
750</li>
751<li>
752<p>
753<a href="git-pull.html">git-pull(1)</a> to merge from your trusted lieutenants.
754</p>
755</li>
756<li>
757<p>
758<a href="git-format-patch.html">git-format-patch(1)</a> to prepare and send suggested
759 alternative to contributors.
760</p>
761</li>
762<li>
763<p>
764<a href="git-revert.html">git-revert(1)</a> to undo botched commits.
765</p>
766</li>
767<li>
768<p>
769<a href="git-push.html">git-push(1)</a> to publish the bleeding edge.
770</p>
771</li>
772</ul>
773<h3>Examples</h3>
774<dl>
775<dt>
776My typical GIT day.
777</dt>
778<dd>
779<div class="listingblock">
780<div class="content">
781<pre><tt>$ git status <b>(1)</b>
782$ git show-branch <b>(2)</b>
783$ mailx <b>(3)</b>
784&amp; s 2 3 4 5 ./+to-apply
785&amp; s 7 8 ./+hold-linus
786&amp; q
Junio C Hamano74640642006-12-27 10:59:55787$ git checkout -b topic/one master
Junio C Hamano1a4e8412005-12-27 08:17:23788$ git am -3 -i -s -u ./+to-apply <b>(4)</b>
789$ compile/test
790$ git checkout -b hold/linus &amp;&amp; git am -3 -i -s -u ./+hold-linus <b>(5)</b>
791$ git checkout topic/one &amp;&amp; git rebase master <b>(6)</b>
Junio C Hamano74640642006-12-27 10:59:55792$ git checkout pu &amp;&amp; git reset --hard next <b>(7)</b>
793$ git merge topic/one topic/two &amp;&amp; git merge hold/linus <b>(8)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23794$ git checkout maint
795$ git cherry-pick master~4 <b>(9)</b>
796$ compile/test
797$ git tag -s -m 'GIT 0.99.9x' v0.99.9x <b>(10)</b>
798$ git fetch ko &amp;&amp; git show-branch master maint 'tags/ko-*' <b>(11)</b>
799$ git push ko <b>(12)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:01800$ git push ko v0.99.9x <b>(13)</b></tt></pre>
801</div></div>
802<ol>
803<li>
804<p>
805see what I was in the middle of doing, if any.
806</p>
807</li>
808<li>
809<p>
810see what topic branches I have and think about how ready
Junio C Hamano1a4e8412005-12-27 08:17:23811they are.
Junio C Hamanoc8d88c22006-04-29 07:02:01812</p>
813</li>
814<li>
815<p>
816read mails, save ones that are applicable, and save others
Junio C Hamano1a4e8412005-12-27 08:17:23817that are not quite ready.
Junio C Hamanoc8d88c22006-04-29 07:02:01818</p>
819</li>
820<li>
821<p>
822apply them, interactively, with my sign-offs.
823</p>
824</li>
825<li>
826<p>
827create topic branch as needed and apply, again with my
Junio C Hamano1a4e8412005-12-27 08:17:23828sign-offs.
Junio C Hamanoc8d88c22006-04-29 07:02:01829</p>
830</li>
831<li>
832<p>
833rebase internal topic branch that has not been merged to the
Junio C Hamano1a4e8412005-12-27 08:17:23834master, nor exposed as a part of a stable branch.
Junio C Hamanoc8d88c22006-04-29 07:02:01835</p>
836</li>
837<li>
838<p>
Junio C Hamano74640642006-12-27 10:59:55839restart <tt>pu</tt> every time from the next.
Junio C Hamanoc8d88c22006-04-29 07:02:01840</p>
841</li>
842<li>
843<p>
844and bundle topic branches still cooking.
845</p>
846</li>
847<li>
848<p>
849backport a critical fix.
850</p>
851</li>
852<li>
853<p>
854create a signed tag.
855</p>
856</li>
857<li>
858<p>
859make sure I did not accidentally rewind master beyond what I
Junio C Hamano74640642006-12-27 10:59:55860already pushed out. <tt>ko</tt> shorthand points at the repository I have
Junio C Hamano1a4e8412005-12-27 08:17:23861at kernel.org, and looks like this:
Junio C Hamanoc8d88c22006-04-29 07:02:01862</p>
Junio C Hamano7da87bb2006-06-06 01:23:49863<div class="listingblock">
864<div class="content">
865<pre><tt>$ cat .git/remotes/ko
866URL: kernel.org:/pub/scm/git/git.git
867Pull: master:refs/tags/ko-master
Junio C Hamano74640642006-12-27 10:59:55868Pull: next:refs/tags/ko-next
Junio C Hamano7da87bb2006-06-06 01:23:49869Pull: maint:refs/tags/ko-maint
870Push: master
Junio C Hamano74640642006-12-27 10:59:55871Push: next
Junio C Hamano7da87bb2006-06-06 01:23:49872Push: +pu
873Push: maint</tt></pre>
874</div></div>
Junio C Hamano74640642006-12-27 10:59:55875<p>In the output from <tt>git show-branch</tt>, <tt>master</tt> should have
876everything <tt>ko-master</tt> has, and <tt>next</tt> should have
877everything <tt>ko-next</tt> has.</p>
Junio C Hamanoc8d88c22006-04-29 07:02:01878</li>
879<li>
880<p>
881push out the bleeding edge.
882</p>
883</li>
884<li>
885<p>
886push the tag out, too.
887</p>
888</li>
889</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23890</dd>
891</dl>
892</div>
893<h2>Repository Administration<a id="Repository Administration"></a></h2>
894<div class="sectionbody">
895<p>A repository administrator uses the following tools to set up
896and maintain access to the repository by developers.</p>
897<ul>
898<li>
899<p>
900<a href="git-daemon.html">git-daemon(1)</a> to allow anonymous download from
901 repository.
902</p>
903</li>
904<li>
905<p>
906<a href="git-shell.html">git-shell(1)</a> can be used as a <em>restricted login shell</em>
907 for shared central repository users.
908</p>
909</li>
910</ul>
911<p><a href="howto/update-hook-example.txt">update hook howto</a> has a good
912example of managing a shared central repository.</p>
913<h3>Examples</h3>
914<dl>
915<dt>
Junio C Hamanoa053d542006-10-27 09:29:13916We assume the following in /etc/services
917</dt>
918<dd>
919<div class="listingblock">
920<div class="content">
921<pre><tt>$ grep 9418 /etc/services
922git 9418/tcp # Git Version Control System</tt></pre>
923</div></div>
924</dd>
925<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23926Run git-daemon to serve /pub/scm from inetd.
927</dt>
928<dd>
929<div class="listingblock">
930<div class="content">
Junio C Hamanobb8fb052006-05-30 07:21:12931<pre><tt>$ grep git /etc/inetd.conf
Junio C Hamano1a4e8412005-12-27 08:17:23932git stream tcp nowait nobody \
Junio C Hamano29f14312006-10-26 08:47:29933 /usr/bin/git-daemon git-daemon --inetd --export-all /pub/scm</tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23934</div></div>
935<p>The actual configuration line should be on one line.</p>
936</dd>
937<dt>
Junio C Hamano7da87bb2006-06-06 01:23:49938Run git-daemon to serve /pub/scm from xinetd.
939</dt>
940<dd>
941<div class="listingblock">
942<div class="content">
943<pre><tt>$ cat /etc/xinetd.d/git-daemon
944# default: off
945# description: The git server offers access to git repositories
946service git
947{
948 disable = no
949 type = UNLISTED
950 port = 9418
951 socket_type = stream
952 wait = no
953 user = nobody
954 server = /usr/bin/git-daemon
Junio C Hamano29f14312006-10-26 08:47:29955 server_args = --inetd --export-all --base-path=/pub/scm
Junio C Hamano7da87bb2006-06-06 01:23:49956 log_on_failure += USERID
957}</tt></pre>
958</div></div>
959<p>Check your xinetd(8) documentation and setup, this is from a Fedora system.
960Others might be different.</p>
961</dd>
962<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23963Give push/pull only access to developers.
964</dt>
965<dd>
966<div class="listingblock">
967<div class="content">
968<pre><tt>$ grep git /etc/passwd <b>(1)</b>
969alice:x:1000:1000::/home/alice:/usr/bin/git-shell
970bob:x:1001:1001::/home/bob:/usr/bin/git-shell
971cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell
972david:x:1003:1003::/home/david:/usr/bin/git-shell
973$ grep git /etc/shells <b>(2)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:01974/usr/bin/git-shell</tt></pre>
975</div></div>
976<ol>
977<li>
978<p>
979log-in shell is set to /usr/bin/git-shell, which does not
Junio C Hamano74640642006-12-27 10:59:55980allow anything but <tt>git push</tt> and <tt>git pull</tt>. The users should
Junio C Hamano1a4e8412005-12-27 08:17:23981get an ssh access to the machine.
Junio C Hamanoc8d88c22006-04-29 07:02:01982</p>
983</li>
984<li>
985<p>
986in many distributions /etc/shells needs to list what is used
987as the login shell.
988</p>
989</li>
990</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23991</dd>
992<dt>
993CVS-style shared repository.
994</dt>
995<dd>
996<div class="listingblock">
997<div class="content">
998<pre><tt>$ grep git /etc/group <b>(1)</b>
999git:x:9418:alice,bob,cindy,david
1000$ cd /home/devo.git
1001$ ls -l <b>(2)</b>
1002 lrwxrwxrwx 1 david git 17 Dec 4 22:40 HEAD -&gt; refs/heads/master
1003 drwxrwsr-x 2 david git 4096 Dec 4 22:40 branches
1004 -rw-rw-r-- 1 david git 84 Dec 4 22:40 config
1005 -rw-rw-r-- 1 david git 58 Dec 4 22:40 description
1006 drwxrwsr-x 2 david git 4096 Dec 4 22:40 hooks
1007 -rw-rw-r-- 1 david git 37504 Dec 4 22:40 index
1008 drwxrwsr-x 2 david git 4096 Dec 4 22:40 info
1009 drwxrwsr-x 4 david git 4096 Dec 4 22:40 objects
1010 drwxrwsr-x 4 david git 4096 Nov 7 14:58 refs
1011 drwxrwsr-x 2 david git 4096 Dec 4 22:40 remotes
1012$ ls -l hooks/update <b>(3)</b>
1013 -r-xr-xr-x 1 david git 3536 Dec 4 22:40 update
1014$ cat info/allowed-users <b>(4)</b>
1015refs/heads/master alice\|cindy
1016refs/heads/doc-update bob
Junio C Hamanoc8d88c22006-04-29 07:02:011017refs/tags/v[0-9]* david</tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:231018</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:011019<ol>
1020<li>
1021<p>
1022place the developers into the same git group.
1023</p>
1024</li>
1025<li>
1026<p>
1027and make the shared repository writable by the group.
1028</p>
1029</li>
1030<li>
1031<p>
1032use update-hook example by Carl from Documentation/howto/
1033for branch policy control.
1034</p>
1035</li>
1036<li>
1037<p>
1038alice and cindy can push into master, only bob can push into doc-update.
1039david is the release manager and is the only person who can
1040create and push version tags.
1041</p>
1042</li>
1043</ol>
Junio C Hamano1a4e8412005-12-27 08:17:231044</dd>
1045<dt>
1046HTTP server to support dumb protocol transfer.
1047</dt>
1048<dd>
1049<div class="listingblock">
1050<div class="content">
1051<pre><tt>dev$ git update-server-info <b>(1)</b>
1052dev$ ftp user@isp.example.com <b>(2)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:011053ftp&gt; cp -r .git /home/user/myproject.git</tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:231054</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:011055<ol>
1056<li>
1057<p>
1058make sure your info/refs and objects/info/packs are up-to-date
1059</p>
1060</li>
1061<li>
1062<p>
1063upload to public HTTP server hosted by your ISP.
1064</p>
1065</li>
1066</ol>
Junio C Hamano1a4e8412005-12-27 08:17:231067</dd>
1068</dl>
1069</div>
1070<div id="footer">
1071<div id="footer-text">
Junio C Hamano20f64da2007-04-04 18:38:301072Last updated 04-Apr-2007 18:34:46 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231073</div>
1074</div>
1075</body>
1076</html>