Autogenerated HTML docs for v1.7.7-237-g34c44
[git/jnareb-git.git] / everyday.html
blob590e5ce280a732dd71d67e8740648fa4314ac300
1 <!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" />
6 <meta name="generator" content="AsciiDoc 8.5.2" />
7 <title>Everyday GIT With 20 Commands Or So</title>
8 <style type="text/css">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
118 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120 div.admonitionblock {
121 margin-top: 1.0em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.0em;
126 margin-bottom: 2.0em;
127 margin-right: 10%;
128 color: #606060;
131 div.content { /* Block element content. */
132 padding: 0;
135 /* Block element titles. */
136 div.title, caption.title {
137 color: #527bbd;
138 font-family: sans-serif;
139 font-weight: bold;
140 text-align: left;
141 margin-top: 1.0em;
142 margin-bottom: 0.5em;
144 div.title + * {
145 margin-top: 0;
148 td div.title:first-child {
149 margin-top: 0.0em;
151 div.content div.title:first-child {
152 margin-top: 0.0em;
154 div.content + div.title {
155 margin-top: 0.0em;
158 div.sidebarblock > div.content {
159 background: #ffffee;
160 border: 1px solid silver;
161 padding: 0.5em;
164 div.listingblock > div.content {
165 border: 1px solid silver;
166 background: #f4f4f4;
167 padding: 0.5em;
170 div.quoteblock, div.verseblock {
171 padding-left: 1.0em;
172 margin-left: 1.0em;
173 margin-right: 10%;
174 border-left: 5px solid #dddddd;
175 color: #777777;
178 div.quoteblock > div.attribution {
179 padding-top: 0.5em;
180 text-align: right;
183 div.verseblock > div.content {
184 white-space: pre;
186 div.verseblock > div.attribution {
187 padding-top: 0.75em;
188 text-align: left;
190 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
191 div.verseblock + div.attribution {
192 text-align: left;
195 div.admonitionblock .icon {
196 vertical-align: top;
197 font-size: 1.1em;
198 font-weight: bold;
199 text-decoration: underline;
200 color: #527bbd;
201 padding-right: 0.5em;
203 div.admonitionblock td.content {
204 padding-left: 0.5em;
205 border-left: 3px solid #dddddd;
208 div.exampleblock > div.content {
209 border-left: 3px solid #dddddd;
210 padding-left: 0.5em;
213 div.imageblock div.content { padding-left: 0; }
214 span.image img { border-style: none; }
215 a.image:visited { color: white; }
217 dl {
218 margin-top: 0.8em;
219 margin-bottom: 0.8em;
221 dt {
222 margin-top: 0.5em;
223 margin-bottom: 0;
224 font-style: normal;
225 color: navy;
227 dd > *:first-child {
228 margin-top: 0.1em;
231 ul, ol {
232 list-style-position: outside;
234 ol.arabic {
235 list-style-type: decimal;
237 ol.loweralpha {
238 list-style-type: lower-alpha;
240 ol.upperalpha {
241 list-style-type: upper-alpha;
243 ol.lowerroman {
244 list-style-type: lower-roman;
246 ol.upperroman {
247 list-style-type: upper-roman;
250 div.compact ul, div.compact ol,
251 div.compact p, div.compact p,
252 div.compact div, div.compact div {
253 margin-top: 0.1em;
254 margin-bottom: 0.1em;
257 div.tableblock > table {
258 border: 3px solid #527bbd;
260 thead, p.table.header {
261 font-family: sans-serif;
262 font-weight: bold;
264 tfoot {
265 font-weight: bold;
267 td > div.verse {
268 white-space: pre;
270 p.table {
271 margin-top: 0;
273 /* Because the table frame attribute is overriden by CSS in most browsers. */
274 div.tableblock > table[frame="void"] {
275 border-style: none;
277 div.tableblock > table[frame="hsides"] {
278 border-left-style: none;
279 border-right-style: none;
281 div.tableblock > table[frame="vsides"] {
282 border-top-style: none;
283 border-bottom-style: none;
287 div.hdlist {
288 margin-top: 0.8em;
289 margin-bottom: 0.8em;
291 div.hdlist tr {
292 padding-bottom: 15px;
294 dt.hdlist1.strong, td.hdlist1.strong {
295 font-weight: bold;
297 td.hdlist1 {
298 vertical-align: top;
299 font-style: normal;
300 padding-right: 0.8em;
301 color: navy;
303 td.hdlist2 {
304 vertical-align: top;
306 div.hdlist.compact tr {
307 margin: 0;
308 padding-bottom: 0;
311 .comment {
312 background: yellow;
315 .footnote, .footnoteref {
316 font-size: 0.8em;
319 span.footnote, span.footnoteref {
320 vertical-align: super;
323 #footnotes {
324 margin: 20px 0 20px 0;
325 padding: 7px 0 0 0;
328 #footnotes div.footnote {
329 margin: 0 0 5px 0;
332 #footnotes hr {
333 border: none;
334 border-top: 1px solid silver;
335 height: 1px;
336 text-align: left;
337 margin-left: 0;
338 width: 20%;
339 min-width: 100px;
343 @media print {
344 div#footer-badges { display: none; }
347 div#toc {
348 margin-bottom: 2.5em;
351 div#toctitle {
352 color: #527bbd;
353 font-family: sans-serif;
354 font-size: 1.1em;
355 font-weight: bold;
356 margin-top: 1.0em;
357 margin-bottom: 0.1em;
360 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
361 margin-top: 0;
362 margin-bottom: 0;
364 div.toclevel2 {
365 margin-left: 2em;
366 font-size: 0.9em;
368 div.toclevel3 {
369 margin-left: 4em;
370 font-size: 0.9em;
372 div.toclevel4 {
373 margin-left: 6em;
374 font-size: 0.9em;
376 /* Workarounds for IE6's broken and incomplete CSS2. */
378 div.sidebar-content {
379 background: #ffffee;
380 border: 1px solid silver;
381 padding: 0.5em;
383 div.sidebar-title, div.image-title {
384 color: #527bbd;
385 font-family: sans-serif;
386 font-weight: bold;
387 margin-top: 0.0em;
388 margin-bottom: 0.5em;
391 div.listingblock div.content {
392 border: 1px solid silver;
393 background: #f4f4f4;
394 padding: 0.5em;
397 div.quoteblock-attribution {
398 padding-top: 0.5em;
399 text-align: right;
402 div.verseblock-content {
403 white-space: pre;
405 div.verseblock-attribution {
406 padding-top: 0.75em;
407 text-align: left;
410 div.exampleblock-content {
411 border-left: 3px solid #dddddd;
412 padding-left: 0.5em;
415 /* IE6 sets dynamically generated links as visited. */
416 div#toc a:visited { color: blue; }
417 </style>
418 <script type="text/javascript">
419 /*<![CDATA[*/
420 window.onload = function(){asciidoc.footnotes();}
421 var asciidoc = { // Namespace.
423 /////////////////////////////////////////////////////////////////////
424 // Table Of Contents generator
425 /////////////////////////////////////////////////////////////////////
427 /* Author: Mihai Bazon, September 2002
428 * http://students.infoiasi.ro/~mishoo
430 * Table Of Content generator
431 * Version: 0.4
433 * Feel free to use this script under the terms of the GNU General Public
434 * License, as long as you do not remove or alter this notice.
437 /* modified by Troy D. Hanson, September 2006. License: GPL */
438 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
440 // toclevels = 1..4.
441 toc: function (toclevels) {
443 function getText(el) {
444 var text = "";
445 for (var i = el.firstChild; i != null; i = i.nextSibling) {
446 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
447 text += i.data;
448 else if (i.firstChild != null)
449 text += getText(i);
451 return text;
454 function TocEntry(el, text, toclevel) {
455 this.element = el;
456 this.text = text;
457 this.toclevel = toclevel;
460 function tocEntries(el, toclevels) {
461 var result = new Array;
462 var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
463 // Function that scans the DOM tree for header elements (the DOM2
464 // nodeIterator API would be a better technique but not supported by all
465 // browsers).
466 var iterate = function (el) {
467 for (var i = el.firstChild; i != null; i = i.nextSibling) {
468 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
469 var mo = re.exec(i.tagName);
470 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
471 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
473 iterate(i);
477 iterate(el);
478 return result;
481 var toc = document.getElementById("toc");
482 var entries = tocEntries(document.getElementById("content"), toclevels);
483 for (var i = 0; i < entries.length; ++i) {
484 var entry = entries[i];
485 if (entry.element.id == "")
486 entry.element.id = "_toc_" + i;
487 var a = document.createElement("a");
488 a.href = "#" + entry.element.id;
489 a.appendChild(document.createTextNode(entry.text));
490 var div = document.createElement("div");
491 div.appendChild(a);
492 div.className = "toclevel" + entry.toclevel;
493 toc.appendChild(div);
495 if (entries.length == 0)
496 toc.parentNode.removeChild(toc);
500 /////////////////////////////////////////////////////////////////////
501 // Footnotes generator
502 /////////////////////////////////////////////////////////////////////
504 /* Based on footnote generation code from:
505 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
508 footnotes: function () {
509 var cont = document.getElementById("content");
510 var noteholder = document.getElementById("footnotes");
511 var spans = cont.getElementsByTagName("span");
512 var refs = {};
513 var n = 0;
514 for (i=0; i<spans.length; i++) {
515 if (spans[i].className == "footnote") {
516 n++;
517 // Use [\s\S] in place of . so multi-line matches work.
518 // Because JavaScript has no s (dotall) regex flag.
519 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
520 noteholder.innerHTML +=
521 "<div class='footnote' id='_footnote_" + n + "'>" +
522 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
523 n + "</a>. " + note + "</div>";
524 spans[i].innerHTML =
525 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
526 "' title='View footnote' class='footnote'>" + n + "</a>]";
527 var id =spans[i].getAttribute("id");
528 if (id != null) refs["#"+id] = n;
531 if (n == 0)
532 noteholder.parentNode.removeChild(noteholder);
533 else {
534 // Process footnoterefs.
535 for (i=0; i<spans.length; i++) {
536 if (spans[i].className == "footnoteref") {
537 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
538 href = href.match(/#.*/)[0]; // Because IE return full URL.
539 n = refs[href];
540 spans[i].innerHTML =
541 "[<a href='#_footnote_" + n +
542 "' title='View footnote' class='footnote'>" + n + "</a>]";
549 /*]]>*/
550 </script>
551 </head>
552 <body>
553 <div id="header">
554 <h1>Everyday GIT With 20 Commands Or So</h1>
555 </div>
556 <div id="content">
557 <div id="preamble">
558 <div class="sectionbody">
559 <div class="paragraph"><p><a href="#Individual Developer (Standalone)">[Individual Developer (Standalone)]</a> commands are essential for
560 anybody who makes a commit, even for somebody who works alone.</p></div>
561 <div class="paragraph"><p>If you work with other people, you will need commands listed in
562 the <a href="#Individual Developer (Participant)">[Individual Developer (Participant)]</a> section as well.</p></div>
563 <div class="paragraph"><p>People who play the <a href="#Integrator">[Integrator]</a> role need to learn some more
564 commands in addition to the above.</p></div>
565 <div class="paragraph"><p><a href="#Repository Administration">[Repository Administration]</a> commands are for system
566 administrators who are responsible for the care and feeding
567 of git repositories.</p></div>
568 </div>
569 </div>
570 <h2 id="_individual_developer_standalone_a_id_individual_developer_standalone_a">Individual Developer (Standalone)<a id="Individual Developer (Standalone)"></a></h2>
571 <div class="sectionbody">
572 <div class="paragraph"><p>A standalone individual developer does not exchange patches with
573 other people, and works alone in a single repository, using the
574 following commands.</p></div>
575 <div class="ulist"><ul>
576 <li>
578 <a href="git-init.html">git-init(1)</a> to create a new repository.
579 </p>
580 </li>
581 <li>
583 <a href="git-show-branch.html">git-show-branch(1)</a> to see where you are.
584 </p>
585 </li>
586 <li>
588 <a href="git-log.html">git-log(1)</a> to see what happened.
589 </p>
590 </li>
591 <li>
593 <a href="git-checkout.html">git-checkout(1)</a> and <a href="git-branch.html">git-branch(1)</a> to switch
594 branches.
595 </p>
596 </li>
597 <li>
599 <a href="git-add.html">git-add(1)</a> to manage the index file.
600 </p>
601 </li>
602 <li>
604 <a href="git-diff.html">git-diff(1)</a> and <a href="git-status.html">git-status(1)</a> to see what
605 you are in the middle of doing.
606 </p>
607 </li>
608 <li>
610 <a href="git-commit.html">git-commit(1)</a> to advance the current branch.
611 </p>
612 </li>
613 <li>
615 <a href="git-reset.html">git-reset(1)</a> and <a href="git-checkout.html">git-checkout(1)</a> (with
616 pathname parameters) to undo changes.
617 </p>
618 </li>
619 <li>
621 <a href="git-merge.html">git-merge(1)</a> to merge between local branches.
622 </p>
623 </li>
624 <li>
626 <a href="git-rebase.html">git-rebase(1)</a> to maintain topic branches.
627 </p>
628 </li>
629 <li>
631 <a href="git-tag.html">git-tag(1)</a> to mark known point.
632 </p>
633 </li>
634 </ul></div>
635 <h3 id="_examples">Examples</h3><div style="clear:left"></div>
636 <div class="dlist"><dl>
637 <dt class="hdlist1">
638 Use a tarball as a starting point for a new repository.
639 </dt>
640 <dd>
641 <div class="listingblock">
642 <div class="content">
643 <pre><tt>$ tar zxf frotz.tar.gz
644 $ cd frotz
645 $ git init
646 $ git add . <b>&lt;1&gt;</b>
647 $ git commit -m "import of frotz source tree."
648 $ git tag v2.43 <b>&lt;2&gt;</b></tt></pre>
649 </div></div>
650 <div class="colist arabic"><ol>
651 <li>
653 add everything under the current directory.
654 </p>
655 </li>
656 <li>
658 make a lightweight, unannotated tag.
659 </p>
660 </li>
661 </ol></div>
662 </dd>
663 <dt class="hdlist1">
664 Create a topic branch and develop.
665 </dt>
666 <dd>
667 <div class="listingblock">
668 <div class="content">
669 <pre><tt>$ git checkout -b alsa-audio <b>&lt;1&gt;</b>
670 $ edit/compile/test
671 $ git checkout -- curses/ux_audio_oss.c <b>&lt;2&gt;</b>
672 $ git add curses/ux_audio_alsa.c <b>&lt;3&gt;</b>
673 $ edit/compile/test
674 $ git diff HEAD <b>&lt;4&gt;</b>
675 $ git commit -a -s <b>&lt;5&gt;</b>
676 $ edit/compile/test
677 $ git reset --soft HEAD^ <b>&lt;6&gt;</b>
678 $ edit/compile/test
679 $ git diff ORIG_HEAD <b>&lt;7&gt;</b>
680 $ git commit -a -c ORIG_HEAD <b>&lt;8&gt;</b>
681 $ git checkout master <b>&lt;9&gt;</b>
682 $ git merge alsa-audio <b>&lt;10&gt;</b>
683 $ git log --since='3 days ago' <b>&lt;11&gt;</b>
684 $ git log v2.43.. curses/ <b>&lt;12&gt;</b></tt></pre>
685 </div></div>
686 <div class="colist arabic"><ol>
687 <li>
689 create a new topic branch.
690 </p>
691 </li>
692 <li>
694 revert your botched changes in <tt>curses/ux_audio_oss.c</tt>.
695 </p>
696 </li>
697 <li>
699 you need to tell git if you added a new file; removal and
700 modification will be caught if you do <tt>git commit -a</tt> later.
701 </p>
702 </li>
703 <li>
705 to see what changes you are committing.
706 </p>
707 </li>
708 <li>
710 commit everything as you have tested, with your sign-off.
711 </p>
712 </li>
713 <li>
715 take the last commit back, keeping what is in the working tree.
716 </p>
717 </li>
718 <li>
720 look at the changes since the premature commit we took back.
721 </p>
722 </li>
723 <li>
725 redo the commit undone in the previous step, using the message
726 you originally wrote.
727 </p>
728 </li>
729 <li>
731 switch to the master branch.
732 </p>
733 </li>
734 <li>
736 merge a topic branch into your master branch.
737 </p>
738 </li>
739 <li>
741 review commit logs; other forms to limit output can be
742 combined and include <tt>--max-count=10</tt> (show 10 commits),
743 <tt>--until=2005-12-10</tt>, etc.
744 </p>
745 </li>
746 <li>
748 view only the changes that touch what&#8217;s in <tt>curses/</tt>
749 directory, since <tt>v2.43</tt> tag.
750 </p>
751 </li>
752 </ol></div>
753 </dd>
754 </dl></div>
755 </div>
756 <h2 id="_individual_developer_participant_a_id_individual_developer_participant_a">Individual Developer (Participant)<a id="Individual Developer (Participant)"></a></h2>
757 <div class="sectionbody">
758 <div class="paragraph"><p>A developer working as a participant in a group project needs to
759 learn how to communicate with others, and uses these commands in
760 addition to the ones needed by a standalone developer.</p></div>
761 <div class="ulist"><ul>
762 <li>
764 <a href="git-clone.html">git-clone(1)</a> from the upstream to prime your local
765 repository.
766 </p>
767 </li>
768 <li>
770 <a href="git-pull.html">git-pull(1)</a> and <a href="git-fetch.html">git-fetch(1)</a> from "origin"
771 to keep up-to-date with the upstream.
772 </p>
773 </li>
774 <li>
776 <a href="git-push.html">git-push(1)</a> to shared repository, if you adopt CVS
777 style shared repository workflow.
778 </p>
779 </li>
780 <li>
782 <a href="git-format-patch.html">git-format-patch(1)</a> to prepare e-mail submission, if
783 you adopt Linux kernel-style public forum workflow.
784 </p>
785 </li>
786 </ul></div>
787 <h3 id="_examples_2">Examples</h3><div style="clear:left"></div>
788 <div class="dlist"><dl>
789 <dt class="hdlist1">
790 Clone the upstream and work on it. Feed changes to upstream.
791 </dt>
792 <dd>
793 <div class="listingblock">
794 <div class="content">
795 <pre><tt>$ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6
796 $ cd my2.6
797 $ edit/compile/test; git commit -a -s <b>&lt;1&gt;</b>
798 $ git format-patch origin <b>&lt;2&gt;</b>
799 $ git pull <b>&lt;3&gt;</b>
800 $ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 <b>&lt;4&gt;</b>
801 $ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <b>&lt;5&gt;</b>
802 $ git reset --hard ORIG_HEAD <b>&lt;6&gt;</b>
803 $ git gc <b>&lt;7&gt;</b>
804 $ git fetch --tags <b>&lt;8&gt;</b></tt></pre>
805 </div></div>
806 <div class="colist arabic"><ol>
807 <li>
809 repeat as needed.
810 </p>
811 </li>
812 <li>
814 extract patches from your branch for e-mail submission.
815 </p>
816 </li>
817 <li>
819 <tt>git pull</tt> fetches from <tt>origin</tt> by default and merges into the
820 current branch.
821 </p>
822 </li>
823 <li>
825 immediately after pulling, look at the changes done upstream
826 since last time we checked, only in the
827 area we are interested in.
828 </p>
829 </li>
830 <li>
832 fetch from a specific branch from a specific repository and merge.
833 </p>
834 </li>
835 <li>
837 revert the pull.
838 </p>
839 </li>
840 <li>
842 garbage collect leftover objects from reverted pull.
843 </p>
844 </li>
845 <li>
847 from time to time, obtain official tags from the <tt>origin</tt>
848 and store them under <tt>.git/refs/tags/</tt>.
849 </p>
850 </li>
851 </ol></div>
852 </dd>
853 <dt class="hdlist1">
854 Push into another repository.
855 </dt>
856 <dd>
857 <div class="listingblock">
858 <div class="content">
859 <pre><tt>satellite$ git clone mothership:frotz frotz <b>&lt;1&gt;</b>
860 satellite$ cd frotz
861 satellite$ git config --get-regexp '^(remote|branch)\.' <b>&lt;2&gt;</b>
862 remote.origin.url mothership:frotz
863 remote.origin.fetch refs/heads/*:refs/remotes/origin/*
864 branch.master.remote origin
865 branch.master.merge refs/heads/master
866 satellite$ git config remote.origin.push \
867 master:refs/remotes/satellite/master <b>&lt;3&gt;</b>
868 satellite$ edit/compile/test/commit
869 satellite$ git push origin <b>&lt;4&gt;</b>
871 mothership$ cd frotz
872 mothership$ git checkout master
873 mothership$ git merge satellite/master <b>&lt;5&gt;</b></tt></pre>
874 </div></div>
875 <div class="colist arabic"><ol>
876 <li>
878 mothership machine has a frotz repository under your home
879 directory; clone from it to start a repository on the satellite
880 machine.
881 </p>
882 </li>
883 <li>
885 clone sets these configuration variables by default.
886 It arranges <tt>git pull</tt> to fetch and store the branches of mothership
887 machine to local <tt>remotes/origin/*</tt> remote-tracking branches.
888 </p>
889 </li>
890 <li>
892 arrange <tt>git push</tt> to push local <tt>master</tt> branch to
893 <tt>remotes/satellite/master</tt> branch of the mothership machine.
894 </p>
895 </li>
896 <li>
898 push will stash our work away on <tt>remotes/satellite/master</tt>
899 remote-tracking branch on the mothership machine. You could use this
900 as a back-up method.
901 </p>
902 </li>
903 <li>
905 on mothership machine, merge the work done on the satellite
906 machine into the master branch.
907 </p>
908 </li>
909 </ol></div>
910 </dd>
911 <dt class="hdlist1">
912 Branch off of a specific tag.
913 </dt>
914 <dd>
915 <div class="listingblock">
916 <div class="content">
917 <pre><tt>$ git checkout -b private2.6.14 v2.6.14 <b>&lt;1&gt;</b>
918 $ edit/compile/test; git commit -a
919 $ git checkout master
920 $ git format-patch -k -m --stdout v2.6.14..private2.6.14 |
921 git am -3 -k <b>&lt;2&gt;</b></tt></pre>
922 </div></div>
923 <div class="colist arabic"><ol>
924 <li>
926 create a private branch based on a well known (but somewhat behind)
927 tag.
928 </p>
929 </li>
930 <li>
932 forward port all changes in <tt>private2.6.14</tt> branch to <tt>master</tt> branch
933 without a formal "merging".
934 </p>
935 </li>
936 </ol></div>
937 </dd>
938 </dl></div>
939 </div>
940 <h2 id="_integrator_a_id_integrator_a">Integrator<a id="Integrator"></a></h2>
941 <div class="sectionbody">
942 <div class="paragraph"><p>A fairly central person acting as the integrator in a group
943 project receives changes made by others, reviews and integrates
944 them and publishes the result for others to use, using these
945 commands in addition to the ones needed by participants.</p></div>
946 <div class="ulist"><ul>
947 <li>
949 <a href="git-am.html">git-am(1)</a> to apply patches e-mailed in from your
950 contributors.
951 </p>
952 </li>
953 <li>
955 <a href="git-pull.html">git-pull(1)</a> to merge from your trusted lieutenants.
956 </p>
957 </li>
958 <li>
960 <a href="git-format-patch.html">git-format-patch(1)</a> to prepare and send suggested
961 alternative to contributors.
962 </p>
963 </li>
964 <li>
966 <a href="git-revert.html">git-revert(1)</a> to undo botched commits.
967 </p>
968 </li>
969 <li>
971 <a href="git-push.html">git-push(1)</a> to publish the bleeding edge.
972 </p>
973 </li>
974 </ul></div>
975 <h3 id="_examples_3">Examples</h3><div style="clear:left"></div>
976 <div class="dlist"><dl>
977 <dt class="hdlist1">
978 My typical GIT day.
979 </dt>
980 <dd>
981 <div class="listingblock">
982 <div class="content">
983 <pre><tt>$ git status <b>&lt;1&gt;</b>
984 $ git show-branch <b>&lt;2&gt;</b>
985 $ mailx <b>&lt;3&gt;</b>
986 &amp; s 2 3 4 5 ./+to-apply
987 &amp; s 7 8 ./+hold-linus
988 &amp; q
989 $ git checkout -b topic/one master
990 $ git am -3 -i -s -u ./+to-apply <b>&lt;4&gt;</b>
991 $ compile/test
992 $ git checkout -b hold/linus &amp;&amp; git am -3 -i -s -u ./+hold-linus <b>&lt;5&gt;</b>
993 $ git checkout topic/one &amp;&amp; git rebase master <b>&lt;6&gt;</b>
994 $ git checkout pu &amp;&amp; git reset --hard next <b>&lt;7&gt;</b>
995 $ git merge topic/one topic/two &amp;&amp; git merge hold/linus <b>&lt;8&gt;</b>
996 $ git checkout maint
997 $ git cherry-pick master~4 <b>&lt;9&gt;</b>
998 $ compile/test
999 $ git tag -s -m "GIT 0.99.9x" v0.99.9x <b>&lt;10&gt;</b>
1000 $ git fetch ko &amp;&amp; git show-branch master maint 'tags/ko-*' <b>&lt;11&gt;</b>
1001 $ git push ko <b>&lt;12&gt;</b>
1002 $ git push ko v0.99.9x <b>&lt;13&gt;</b></tt></pre>
1003 </div></div>
1004 <div class="colist arabic"><ol>
1005 <li>
1007 see what I was in the middle of doing, if any.
1008 </p>
1009 </li>
1010 <li>
1012 see what topic branches I have and think about how ready
1013 they are.
1014 </p>
1015 </li>
1016 <li>
1018 read mails, save ones that are applicable, and save others
1019 that are not quite ready.
1020 </p>
1021 </li>
1022 <li>
1024 apply them, interactively, with my sign-offs.
1025 </p>
1026 </li>
1027 <li>
1029 create topic branch as needed and apply, again with my
1030 sign-offs.
1031 </p>
1032 </li>
1033 <li>
1035 rebase internal topic branch that has not been merged to the
1036 master, nor exposed as a part of a stable branch.
1037 </p>
1038 </li>
1039 <li>
1041 restart <tt>pu</tt> every time from the next.
1042 </p>
1043 </li>
1044 <li>
1046 and bundle topic branches still cooking.
1047 </p>
1048 </li>
1049 <li>
1051 backport a critical fix.
1052 </p>
1053 </li>
1054 <li>
1056 create a signed tag.
1057 </p>
1058 </li>
1059 <li>
1061 make sure I did not accidentally rewind master beyond what I
1062 already pushed out. <tt>ko</tt> shorthand points at the repository I have
1063 at kernel.org, and looks like this:
1064 </p>
1065 <div class="listingblock">
1066 <div class="content">
1067 <pre><tt>$ cat .git/remotes/ko
1068 URL: kernel.org:/pub/scm/git/git.git
1069 Pull: master:refs/tags/ko-master
1070 Pull: next:refs/tags/ko-next
1071 Pull: maint:refs/tags/ko-maint
1072 Push: master
1073 Push: next
1074 Push: +pu
1075 Push: maint</tt></pre>
1076 </div></div>
1077 <div class="paragraph"><p>In the output from <tt>git show-branch</tt>, <tt>master</tt> should have
1078 everything <tt>ko-master</tt> has, and <tt>next</tt> should have
1079 everything <tt>ko-next</tt> has.</p></div>
1080 </li>
1081 <li>
1083 push out the bleeding edge.
1084 </p>
1085 </li>
1086 <li>
1088 push the tag out, too.
1089 </p>
1090 </li>
1091 </ol></div>
1092 </dd>
1093 </dl></div>
1094 </div>
1095 <h2 id="_repository_administration_a_id_repository_administration_a">Repository Administration<a id="Repository Administration"></a></h2>
1096 <div class="sectionbody">
1097 <div class="paragraph"><p>A repository administrator uses the following tools to set up
1098 and maintain access to the repository by developers.</p></div>
1099 <div class="ulist"><ul>
1100 <li>
1102 <a href="git-daemon.html">git-daemon(1)</a> to allow anonymous download from
1103 repository.
1104 </p>
1105 </li>
1106 <li>
1108 <a href="git-shell.html">git-shell(1)</a> can be used as a <em>restricted login shell</em>
1109 for shared central repository users.
1110 </p>
1111 </li>
1112 </ul></div>
1113 <div class="paragraph"><p><a href="howto/update-hook-example.txt">update hook howto</a> has a good
1114 example of managing a shared central repository.</p></div>
1115 <h3 id="_examples_4">Examples</h3><div style="clear:left"></div>
1116 <div class="dlist"><dl>
1117 <dt class="hdlist1">
1118 We assume the following in /etc/services
1119 </dt>
1120 <dd>
1121 <div class="listingblock">
1122 <div class="content">
1123 <pre><tt>$ grep 9418 /etc/services
1124 git 9418/tcp # Git Version Control System</tt></pre>
1125 </div></div>
1126 </dd>
1127 <dt class="hdlist1">
1128 Run git-daemon to serve /pub/scm from inetd.
1129 </dt>
1130 <dd>
1131 <div class="listingblock">
1132 <div class="content">
1133 <pre><tt>$ grep git /etc/inetd.conf
1134 git stream tcp nowait nobody \
1135 /usr/bin/git-daemon git-daemon --inetd --export-all /pub/scm</tt></pre>
1136 </div></div>
1137 <div class="paragraph"><p>The actual configuration line should be on one line.</p></div>
1138 </dd>
1139 <dt class="hdlist1">
1140 Run git-daemon to serve /pub/scm from xinetd.
1141 </dt>
1142 <dd>
1143 <div class="listingblock">
1144 <div class="content">
1145 <pre><tt>$ cat /etc/xinetd.d/git-daemon
1146 # default: off
1147 # description: The git server offers access to git repositories
1148 service git
1150 disable = no
1151 type = UNLISTED
1152 port = 9418
1153 socket_type = stream
1154 wait = no
1155 user = nobody
1156 server = /usr/bin/git-daemon
1157 server_args = --inetd --export-all --base-path=/pub/scm
1158 log_on_failure += USERID
1159 }</tt></pre>
1160 </div></div>
1161 <div class="paragraph"><p>Check your xinetd(8) documentation and setup, this is from a Fedora system.
1162 Others might be different.</p></div>
1163 </dd>
1164 <dt class="hdlist1">
1165 Give push/pull only access to developers.
1166 </dt>
1167 <dd>
1168 <div class="listingblock">
1169 <div class="content">
1170 <pre><tt>$ grep git /etc/passwd <b>&lt;1&gt;</b>
1171 alice:x:1000:1000::/home/alice:/usr/bin/git-shell
1172 bob:x:1001:1001::/home/bob:/usr/bin/git-shell
1173 cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell
1174 david:x:1003:1003::/home/david:/usr/bin/git-shell
1175 $ grep git /etc/shells <b>&lt;2&gt;</b>
1176 /usr/bin/git-shell</tt></pre>
1177 </div></div>
1178 <div class="colist arabic"><ol>
1179 <li>
1181 log-in shell is set to /usr/bin/git-shell, which does not
1182 allow anything but <tt>git push</tt> and <tt>git pull</tt>. The users should
1183 get an ssh access to the machine.
1184 </p>
1185 </li>
1186 <li>
1188 in many distributions /etc/shells needs to list what is used
1189 as the login shell.
1190 </p>
1191 </li>
1192 </ol></div>
1193 </dd>
1194 <dt class="hdlist1">
1195 CVS-style shared repository.
1196 </dt>
1197 <dd>
1198 <div class="listingblock">
1199 <div class="content">
1200 <pre><tt>$ grep git /etc/group <b>&lt;1&gt;</b>
1201 git:x:9418:alice,bob,cindy,david
1202 $ cd /home/devo.git
1203 $ ls -l <b>&lt;2&gt;</b>
1204 lrwxrwxrwx 1 david git 17 Dec 4 22:40 HEAD -&gt; refs/heads/master
1205 drwxrwsr-x 2 david git 4096 Dec 4 22:40 branches
1206 -rw-rw-r-- 1 david git 84 Dec 4 22:40 config
1207 -rw-rw-r-- 1 david git 58 Dec 4 22:40 description
1208 drwxrwsr-x 2 david git 4096 Dec 4 22:40 hooks
1209 -rw-rw-r-- 1 david git 37504 Dec 4 22:40 index
1210 drwxrwsr-x 2 david git 4096 Dec 4 22:40 info
1211 drwxrwsr-x 4 david git 4096 Dec 4 22:40 objects
1212 drwxrwsr-x 4 david git 4096 Nov 7 14:58 refs
1213 drwxrwsr-x 2 david git 4096 Dec 4 22:40 remotes
1214 $ ls -l hooks/update <b>&lt;3&gt;</b>
1215 -r-xr-xr-x 1 david git 3536 Dec 4 22:40 update
1216 $ cat info/allowed-users <b>&lt;4&gt;</b>
1217 refs/heads/master alice\|cindy
1218 refs/heads/doc-update bob
1219 refs/tags/v[0-9]* david</tt></pre>
1220 </div></div>
1221 <div class="colist arabic"><ol>
1222 <li>
1224 place the developers into the same git group.
1225 </p>
1226 </li>
1227 <li>
1229 and make the shared repository writable by the group.
1230 </p>
1231 </li>
1232 <li>
1234 use update-hook example by Carl from Documentation/howto/
1235 for branch policy control.
1236 </p>
1237 </li>
1238 <li>
1240 alice and cindy can push into master, only bob can push into doc-update.
1241 david is the release manager and is the only person who can
1242 create and push version tags.
1243 </p>
1244 </li>
1245 </ol></div>
1246 </dd>
1247 <dt class="hdlist1">
1248 HTTP server to support dumb protocol transfer.
1249 </dt>
1250 <dd>
1251 <div class="listingblock">
1252 <div class="content">
1253 <pre><tt>dev$ git update-server-info <b>&lt;1&gt;</b>
1254 dev$ ftp user@isp.example.com <b>&lt;2&gt;</b>
1255 ftp&gt; cp -r .git /home/user/myproject.git</tt></pre>
1256 </div></div>
1257 <div class="colist arabic"><ol>
1258 <li>
1260 make sure your info/refs and objects/info/packs are up-to-date
1261 </p>
1262 </li>
1263 <li>
1265 upload to public HTTP server hosted by your ISP.
1266 </p>
1267 </li>
1268 </ol></div>
1269 </dd>
1270 </dl></div>
1271 </div>
1272 </div>
1273 <div id="footnotes"><hr /></div>
1274 <div id="footer">
1275 <div id="footer-text">
1276 Last updated 2011-09-21 23:01:14 PDT
1277 </div>
1278 </div>
1279 </body>
1280 </html>