Autogenerated HTML docs for v1.7.7-290-gc9e7aa
[git/jnareb-git.git] / gitworkflows.html
blob7a6896de432bdf0e3820a1ca4aadd9861e17f169
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>gitworkflows(7)</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 /* Overrides for manpage documents */
377 h1 {
378 padding-top: 0.5em;
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver;
381 border-bottom: 2px solid silver;
383 h2 {
384 border-style: none;
386 div.sectionbody {
387 margin-left: 5%;
390 @media print {
391 div#toc { display: none; }
394 /* Workarounds for IE6's broken and incomplete CSS2. */
396 div.sidebar-content {
397 background: #ffffee;
398 border: 1px solid silver;
399 padding: 0.5em;
401 div.sidebar-title, div.image-title {
402 color: #527bbd;
403 font-family: sans-serif;
404 font-weight: bold;
405 margin-top: 0.0em;
406 margin-bottom: 0.5em;
409 div.listingblock div.content {
410 border: 1px solid silver;
411 background: #f4f4f4;
412 padding: 0.5em;
415 div.quoteblock-attribution {
416 padding-top: 0.5em;
417 text-align: right;
420 div.verseblock-content {
421 white-space: pre;
423 div.verseblock-attribution {
424 padding-top: 0.75em;
425 text-align: left;
428 div.exampleblock-content {
429 border-left: 3px solid #dddddd;
430 padding-left: 0.5em;
433 /* IE6 sets dynamically generated links as visited. */
434 div#toc a:visited { color: blue; }
435 </style>
436 <script type="text/javascript">
437 /*<![CDATA[*/
438 window.onload = function(){asciidoc.footnotes();}
439 var asciidoc = { // Namespace.
441 /////////////////////////////////////////////////////////////////////
442 // Table Of Contents generator
443 /////////////////////////////////////////////////////////////////////
445 /* Author: Mihai Bazon, September 2002
446 * http://students.infoiasi.ro/~mishoo
448 * Table Of Content generator
449 * Version: 0.4
451 * Feel free to use this script under the terms of the GNU General Public
452 * License, as long as you do not remove or alter this notice.
455 /* modified by Troy D. Hanson, September 2006. License: GPL */
456 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
458 // toclevels = 1..4.
459 toc: function (toclevels) {
461 function getText(el) {
462 var text = "";
463 for (var i = el.firstChild; i != null; i = i.nextSibling) {
464 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
465 text += i.data;
466 else if (i.firstChild != null)
467 text += getText(i);
469 return text;
472 function TocEntry(el, text, toclevel) {
473 this.element = el;
474 this.text = text;
475 this.toclevel = toclevel;
478 function tocEntries(el, toclevels) {
479 var result = new Array;
480 var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
481 // Function that scans the DOM tree for header elements (the DOM2
482 // nodeIterator API would be a better technique but not supported by all
483 // browsers).
484 var iterate = function (el) {
485 for (var i = el.firstChild; i != null; i = i.nextSibling) {
486 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
487 var mo = re.exec(i.tagName);
488 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
489 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
491 iterate(i);
495 iterate(el);
496 return result;
499 var toc = document.getElementById("toc");
500 var entries = tocEntries(document.getElementById("content"), toclevels);
501 for (var i = 0; i < entries.length; ++i) {
502 var entry = entries[i];
503 if (entry.element.id == "")
504 entry.element.id = "_toc_" + i;
505 var a = document.createElement("a");
506 a.href = "#" + entry.element.id;
507 a.appendChild(document.createTextNode(entry.text));
508 var div = document.createElement("div");
509 div.appendChild(a);
510 div.className = "toclevel" + entry.toclevel;
511 toc.appendChild(div);
513 if (entries.length == 0)
514 toc.parentNode.removeChild(toc);
518 /////////////////////////////////////////////////////////////////////
519 // Footnotes generator
520 /////////////////////////////////////////////////////////////////////
522 /* Based on footnote generation code from:
523 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
526 footnotes: function () {
527 var cont = document.getElementById("content");
528 var noteholder = document.getElementById("footnotes");
529 var spans = cont.getElementsByTagName("span");
530 var refs = {};
531 var n = 0;
532 for (i=0; i<spans.length; i++) {
533 if (spans[i].className == "footnote") {
534 n++;
535 // Use [\s\S] in place of . so multi-line matches work.
536 // Because JavaScript has no s (dotall) regex flag.
537 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
538 noteholder.innerHTML +=
539 "<div class='footnote' id='_footnote_" + n + "'>" +
540 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
541 n + "</a>. " + note + "</div>";
542 spans[i].innerHTML =
543 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
544 "' title='View footnote' class='footnote'>" + n + "</a>]";
545 var id =spans[i].getAttribute("id");
546 if (id != null) refs["#"+id] = n;
549 if (n == 0)
550 noteholder.parentNode.removeChild(noteholder);
551 else {
552 // Process footnoterefs.
553 for (i=0; i<spans.length; i++) {
554 if (spans[i].className == "footnoteref") {
555 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
556 href = href.match(/#.*/)[0]; // Because IE return full URL.
557 n = refs[href];
558 spans[i].innerHTML =
559 "[<a href='#_footnote_" + n +
560 "' title='View footnote' class='footnote'>" + n + "</a>]";
567 /*]]>*/
568 </script>
569 </head>
570 <body>
571 <div id="header">
572 <h1>
573 gitworkflows(7) Manual Page
574 </h1>
575 <h2>NAME</h2>
576 <div class="sectionbody">
577 <p>gitworkflows -
578 An overview of recommended workflows with git
579 </p>
580 </div>
581 </div>
582 <div id="content">
583 <h2 id="_synopsis">SYNOPSIS</h2>
584 <div class="sectionbody">
585 <div class="verseblock">
586 <div class="verseblock-content">git *</div>
587 <div class="verseblock-attribution">
588 </div></div>
589 </div>
590 <h2 id="_description">DESCRIPTION</h2>
591 <div class="sectionbody">
592 <div class="paragraph"><p>This document attempts to write down and motivate some of the workflow
593 elements used for <tt>git.git</tt> itself. Many ideas apply in general,
594 though the full workflow is rarely required for smaller projects with
595 fewer people involved.</p></div>
596 <div class="paragraph"><p>We formulate a set of <em>rules</em> for quick reference, while the prose
597 tries to motivate each of them. Do not always take them literally;
598 you should value good reasons for your actions higher than manpages
599 such as this one.</p></div>
600 </div>
601 <h2 id="_separate_changes">SEPARATE CHANGES</h2>
602 <div class="sectionbody">
603 <div class="paragraph"><p>As a general rule, you should try to split your changes into small
604 logical steps, and commit each of them. They should be consistent,
605 working independently of any later commits, pass the test suite, etc.
606 This makes the review process much easier, and the history much more
607 useful for later inspection and analysis, for example with
608 <a href="git-blame.html">git-blame(1)</a> and <a href="git-bisect.html">git-bisect(1)</a>.</p></div>
609 <div class="paragraph"><p>To achieve this, try to split your work into small steps from the very
610 beginning. It is always easier to squash a few commits together than
611 to split one big commit into several. Don&#8217;t be afraid of making too
612 small or imperfect steps along the way. You can always go back later
613 and edit the commits with <tt>git rebase --interactive</tt> before you
614 publish them. You can use <tt>git stash save --keep-index</tt> to run the
615 test suite independent of other uncommitted changes; see the EXAMPLES
616 section of <a href="git-stash.html">git-stash(1)</a>.</p></div>
617 </div>
618 <h2 id="_managing_branches">MANAGING BRANCHES</h2>
619 <div class="sectionbody">
620 <div class="paragraph"><p>There are two main tools that can be used to include changes from one
621 branch on another: <a href="git-merge.html">git-merge(1)</a> and
622 <a href="git-cherry-pick.html">git-cherry-pick(1)</a>.</p></div>
623 <div class="paragraph"><p>Merges have many advantages, so we try to solve as many problems as
624 possible with merges alone. Cherry-picking is still occasionally
625 useful; see "Merging upwards" below for an example.</p></div>
626 <div class="paragraph"><p>Most importantly, merging works at the branch level, while
627 cherry-picking works at the commit level. This means that a merge can
628 carry over the changes from 1, 10, or 1000 commits with equal ease,
629 which in turn means the workflow scales much better to a large number
630 of contributors (and contributions). Merges are also easier to
631 understand because a merge commit is a "promise" that all changes from
632 all its parents are now included.</p></div>
633 <div class="paragraph"><p>There is a tradeoff of course: merges require a more careful branch
634 management. The following subsections discuss the important points.</p></div>
635 <h3 id="_graduation">Graduation</h3><div style="clear:left"></div>
636 <div class="paragraph"><p>As a given feature goes from experimental to stable, it also
637 "graduates" between the corresponding branches of the software.
638 <tt>git.git</tt> uses the following <em>integration branches</em>:</p></div>
639 <div class="ulist"><ul>
640 <li>
642 <em>maint</em> tracks the commits that should go into the next "maintenance
643 release", i.e., update of the last released stable version;
644 </p>
645 </li>
646 <li>
648 <em>master</em> tracks the commits that should go into the next release;
649 </p>
650 </li>
651 <li>
653 <em>next</em> is intended as a testing branch for topics being tested for
654 stability for master.
655 </p>
656 </li>
657 </ul></div>
658 <div class="paragraph"><p>There is a fourth official branch that is used slightly differently:</p></div>
659 <div class="ulist"><ul>
660 <li>
662 <em>pu</em> (proposed updates) is an integration branch for things that are
663 not quite ready for inclusion yet (see "Integration Branches"
664 below).
665 </p>
666 </li>
667 </ul></div>
668 <div class="paragraph"><p>Each of the four branches is usually a direct descendant of the one
669 above it.</p></div>
670 <div class="paragraph"><p>Conceptually, the feature enters at an unstable branch (usually <em>next</em>
671 or <em>pu</em>), and "graduates" to <em>master</em> for the next release once it is
672 considered stable enough.</p></div>
673 <h3 id="_merging_upwards">Merging upwards</h3><div style="clear:left"></div>
674 <div class="paragraph"><p>The "downwards graduation" discussed above cannot be done by actually
675 merging downwards, however, since that would merge <em>all</em> changes on
676 the unstable branch into the stable one. Hence the following:</p></div>
677 <div class="exampleblock">
678 <div class="title">Rule: Merge upwards</div>
679 <div class="exampleblock-content">
680 <div class="paragraph"><p>Always commit your fixes to the oldest supported branch that require
681 them. Then (periodically) merge the integration branches upwards into each
682 other.</p></div>
683 </div></div>
684 <div class="paragraph"><p>This gives a very controlled flow of fixes. If you notice that you
685 have applied a fix to e.g. <em>master</em> that is also required in <em>maint</em>,
686 you will need to cherry-pick it (using <a href="git-cherry-pick.html">git-cherry-pick(1)</a>)
687 downwards. This will happen a few times and is nothing to worry about
688 unless you do it very frequently.</p></div>
689 <h3 id="_topic_branches">Topic branches</h3><div style="clear:left"></div>
690 <div class="paragraph"><p>Any nontrivial feature will require several patches to implement, and
691 may get extra bugfixes or improvements during its lifetime.</p></div>
692 <div class="paragraph"><p>Committing everything directly on the integration branches leads to many
693 problems: Bad commits cannot be undone, so they must be reverted one
694 by one, which creates confusing histories and further error potential
695 when you forget to revert part of a group of changes. Working in
696 parallel mixes up the changes, creating further confusion.</p></div>
697 <div class="paragraph"><p>Use of "topic branches" solves these problems. The name is pretty
698 self explanatory, with a caveat that comes from the "merge upwards"
699 rule above:</p></div>
700 <div class="exampleblock">
701 <div class="title">Rule: Topic branches</div>
702 <div class="exampleblock-content">
703 <div class="paragraph"><p>Make a side branch for every topic (feature, bugfix, &#8230;). Fork it off
704 at the oldest integration branch that you will eventually want to merge it
705 into.</p></div>
706 </div></div>
707 <div class="paragraph"><p>Many things can then be done very naturally:</p></div>
708 <div class="ulist"><ul>
709 <li>
711 To get the feature/bugfix into an integration branch, simply merge
712 it. If the topic has evolved further in the meantime, merge again.
713 (Note that you do not necessarily have to merge it to the oldest
714 integration branch first. For example, you can first merge a bugfix
715 to <em>next</em>, give it some testing time, and merge to <em>maint</em> when you
716 know it is stable.)
717 </p>
718 </li>
719 <li>
721 If you find you need new features from the branch <em>other</em> to continue
722 working on your topic, merge <em>other</em> to <em>topic</em>. (However, do not
723 do this "just habitually", see below.)
724 </p>
725 </li>
726 <li>
728 If you find you forked off the wrong branch and want to move it
729 "back in time", use <a href="git-rebase.html">git-rebase(1)</a>.
730 </p>
731 </li>
732 </ul></div>
733 <div class="paragraph"><p>Note that the last point clashes with the other two: a topic that has
734 been merged elsewhere should not be rebased. See the section on
735 RECOVERING FROM UPSTREAM REBASE in <a href="git-rebase.html">git-rebase(1)</a>.</p></div>
736 <div class="paragraph"><p>We should point out that "habitually" (regularly for no real reason)
737 merging an integration branch into your topics&#8201;&#8212;&#8201;and by extension,
738 merging anything upstream into anything downstream on a regular basis&#8201;&#8212;&#8201;is frowned upon:</p></div>
739 <div class="exampleblock">
740 <div class="title">Rule: Merge to downstream only at well-defined points</div>
741 <div class="exampleblock-content">
742 <div class="paragraph"><p>Do not merge to downstream except with a good reason: upstream API
743 changes affect your branch; your branch no longer merges to upstream
744 cleanly; etc.</p></div>
745 </div></div>
746 <div class="paragraph"><p>Otherwise, the topic that was merged to suddenly contains more than a
747 single (well-separated) change. The many resulting small merges will
748 greatly clutter up history. Anyone who later investigates the history
749 of a file will have to find out whether that merge affected the topic
750 in development. An upstream might even inadvertently be merged into a
751 "more stable" branch. And so on.</p></div>
752 <h3 id="_throw_away_integration">Throw-away integration</h3><div style="clear:left"></div>
753 <div class="paragraph"><p>If you followed the last paragraph, you will now have many small topic
754 branches, and occasionally wonder how they interact. Perhaps the
755 result of merging them does not even work? But on the other hand, we
756 want to avoid merging them anywhere "stable" because such merges
757 cannot easily be undone.</p></div>
758 <div class="paragraph"><p>The solution, of course, is to make a merge that we can undo: merge
759 into a throw-away branch.</p></div>
760 <div class="exampleblock">
761 <div class="title">Rule: Throw-away integration branches</div>
762 <div class="exampleblock-content">
763 <div class="paragraph"><p>To test the interaction of several topics, merge them into a
764 throw-away branch. You must never base any work on such a branch!</p></div>
765 </div></div>
766 <div class="paragraph"><p>If you make it (very) clear that this branch is going to be deleted
767 right after the testing, you can even publish this branch, for example
768 to give the testers a chance to work with it, or other developers a
769 chance to see if their in-progress work will be compatible. <tt>git.git</tt>
770 has such an official throw-away integration branch called <em>pu</em>.</p></div>
771 <h3 id="_branch_management_for_a_release">Branch management for a release</h3><div style="clear:left"></div>
772 <div class="paragraph"><p>Assuming you are using the merge approach discussed above, when you
773 are releasing your project you will need to do some additional branch
774 management work.</p></div>
775 <div class="paragraph"><p>A feature release is created from the <em>master</em> branch, since <em>master</em>
776 tracks the commits that should go into the next feature release.</p></div>
777 <div class="paragraph"><p>The <em>master</em> branch is supposed to be a superset of <em>maint</em>. If this
778 condition does not hold, then <em>maint</em> contains some commits that
779 are not included on <em>master</em>. The fixes represented by those commits
780 will therefore not be included in your feature release.</p></div>
781 <div class="paragraph"><p>To verify that <em>master</em> is indeed a superset of <em>maint</em>, use git log:</p></div>
782 <div class="exampleblock">
783 <div class="title">Recipe: Verify <em>master</em> is a superset of <em>maint</em></div>
784 <div class="exampleblock-content">
785 <div class="paragraph"><p><tt>git log master..maint</tt></p></div>
786 </div></div>
787 <div class="paragraph"><p>This command should not list any commits. Otherwise, check out
788 <em>master</em> and merge <em>maint</em> into it.</p></div>
789 <div class="paragraph"><p>Now you can proceed with the creation of the feature release. Apply a
790 tag to the tip of <em>master</em> indicating the release version:</p></div>
791 <div class="exampleblock">
792 <div class="title">Recipe: Release tagging</div>
793 <div class="exampleblock-content">
794 <div class="paragraph"><p><tt>git tag -s -m "GIT X.Y.Z" vX.Y.Z master</tt></p></div>
795 </div></div>
796 <div class="paragraph"><p>You need to push the new tag to a public git server (see
797 "DISTRIBUTED WORKFLOWS" below). This makes the tag available to
798 others tracking your project. The push could also trigger a
799 post-update hook to perform release-related items such as building
800 release tarballs and preformatted documentation pages.</p></div>
801 <div class="paragraph"><p>Similarly, for a maintenance release, <em>maint</em> is tracking the commits
802 to be released. Therefore, in the steps above simply tag and push
803 <em>maint</em> rather than <em>master</em>.</p></div>
804 <h3 id="_maintenance_branch_management_after_a_feature_release">Maintenance branch management after a feature release</h3><div style="clear:left"></div>
805 <div class="paragraph"><p>After a feature release, you need to manage your maintenance branches.</p></div>
806 <div class="paragraph"><p>First, if you wish to continue to release maintenance fixes for the
807 feature release made before the recent one, then you must create
808 another branch to track commits for that previous release.</p></div>
809 <div class="paragraph"><p>To do this, the current maintenance branch is copied to another branch
810 named with the previous release version number (e.g. maint-X.Y.(Z-1)
811 where X.Y.Z is the current release).</p></div>
812 <div class="exampleblock">
813 <div class="title">Recipe: Copy maint</div>
814 <div class="exampleblock-content">
815 <div class="paragraph"><p><tt>git branch maint-X.Y.(Z-1) maint</tt></p></div>
816 </div></div>
817 <div class="paragraph"><p>The <em>maint</em> branch should now be fast-forwarded to the newly released
818 code so that maintenance fixes can be tracked for the current release:</p></div>
819 <div class="exampleblock">
820 <div class="title">Recipe: Update maint to new release</div>
821 <div class="exampleblock-content">
822 <div class="ulist"><ul>
823 <li>
825 <tt>git checkout maint</tt>
826 </p>
827 </li>
828 <li>
830 <tt>git merge --ff-only master</tt>
831 </p>
832 </li>
833 </ul></div>
834 </div></div>
835 <div class="paragraph"><p>If the merge fails because it is not a fast-forward, then it is
836 possible some fixes on <em>maint</em> were missed in the feature release.
837 This will not happen if the content of the branches was verified as
838 described in the previous section.</p></div>
839 <h3 id="_branch_management_for_next_and_pu_after_a_feature_release">Branch management for next and pu after a feature release</h3><div style="clear:left"></div>
840 <div class="paragraph"><p>After a feature release, the integration branch <em>next</em> may optionally be
841 rewound and rebuilt from the tip of <em>master</em> using the surviving
842 topics on <em>next</em>:</p></div>
843 <div class="exampleblock">
844 <div class="title">Recipe: Rewind and rebuild next</div>
845 <div class="exampleblock-content">
846 <div class="ulist"><ul>
847 <li>
849 <tt>git checkout next</tt>
850 </p>
851 </li>
852 <li>
854 <tt>git reset --hard master</tt>
855 </p>
856 </li>
857 <li>
859 <tt>git merge ai/topic_in_next1</tt>
860 </p>
861 </li>
862 <li>
864 <tt>git merge ai/topic_in_next2</tt>
865 </p>
866 </li>
867 <li>
869 &#8230;
870 </p>
871 </li>
872 </ul></div>
873 </div></div>
874 <div class="paragraph"><p>The advantage of doing this is that the history of <em>next</em> will be
875 clean. For example, some topics merged into <em>next</em> may have initially
876 looked promising, but were later found to be undesirable or premature.
877 In such a case, the topic is reverted out of <em>next</em> but the fact
878 remains in the history that it was once merged and reverted. By
879 recreating <em>next</em>, you give another incarnation of such topics a clean
880 slate to retry, and a feature release is a good point in history to do
881 so.</p></div>
882 <div class="paragraph"><p>If you do this, then you should make a public announcement indicating
883 that <em>next</em> was rewound and rebuilt.</p></div>
884 <div class="paragraph"><p>The same rewind and rebuild process may be followed for <em>pu</em>. A public
885 announcement is not necessary since <em>pu</em> is a throw-away branch, as
886 described above.</p></div>
887 </div>
888 <h2 id="_distributed_workflows">DISTRIBUTED WORKFLOWS</h2>
889 <div class="sectionbody">
890 <div class="paragraph"><p>After the last section, you should know how to manage topics. In
891 general, you will not be the only person working on the project, so
892 you will have to share your work.</p></div>
893 <div class="paragraph"><p>Roughly speaking, there are two important workflows: merge and patch.
894 The important difference is that the merge workflow can propagate full
895 history, including merges, while patches cannot. Both workflows can
896 be used in parallel: in <tt>git.git</tt>, only subsystem maintainers use
897 the merge workflow, while everyone else sends patches.</p></div>
898 <div class="paragraph"><p>Note that the maintainer(s) may impose restrictions, such as
899 "Signed-off-by" requirements, that all commits/patches submitted for
900 inclusion must adhere to. Consult your project&#8217;s documentation for
901 more information.</p></div>
902 <h3 id="_merge_workflow">Merge workflow</h3><div style="clear:left"></div>
903 <div class="paragraph"><p>The merge workflow works by copying branches between upstream and
904 downstream. Upstream can merge contributions into the official
905 history; downstream base their work on the official history.</p></div>
906 <div class="paragraph"><p>There are three main tools that can be used for this:</p></div>
907 <div class="ulist"><ul>
908 <li>
910 <a href="git-push.html">git-push(1)</a> copies your branches to a remote repository,
911 usually to one that can be read by all involved parties;
912 </p>
913 </li>
914 <li>
916 <a href="git-fetch.html">git-fetch(1)</a> that copies remote branches to your repository;
918 </p>
919 </li>
920 <li>
922 <a href="git-pull.html">git-pull(1)</a> that does fetch and merge in one go.
923 </p>
924 </li>
925 </ul></div>
926 <div class="paragraph"><p>Note the last point. Do <em>not</em> use <em>git pull</em> unless you actually want
927 to merge the remote branch.</p></div>
928 <div class="paragraph"><p>Getting changes out is easy:</p></div>
929 <div class="exampleblock">
930 <div class="title">Recipe: Push/pull: Publishing branches/topics</div>
931 <div class="exampleblock-content">
932 <div class="paragraph"><p><tt>git push &lt;remote&gt; &lt;branch&gt;</tt> and tell everyone where they can fetch
933 from.</p></div>
934 </div></div>
935 <div class="paragraph"><p>You will still have to tell people by other means, such as mail. (Git
936 provides the <a href="git-request-pull.html">git-request-pull(1)</a> to send preformatted pull
937 requests to upstream maintainers to simplify this task.)</p></div>
938 <div class="paragraph"><p>If you just want to get the newest copies of the integration branches,
939 staying up to date is easy too:</p></div>
940 <div class="exampleblock">
941 <div class="title">Recipe: Push/pull: Staying up to date</div>
942 <div class="exampleblock-content">
943 <div class="paragraph"><p>Use <tt>git fetch &lt;remote&gt;</tt> or <tt>git remote update</tt> to stay up to date.</p></div>
944 </div></div>
945 <div class="paragraph"><p>Then simply fork your topic branches from the stable remotes as
946 explained earlier.</p></div>
947 <div class="paragraph"><p>If you are a maintainer and would like to merge other people&#8217;s topic
948 branches to the integration branches, they will typically send a
949 request to do so by mail. Such a request looks like</p></div>
950 <div class="listingblock">
951 <div class="content">
952 <pre><tt>Please pull from
953 &lt;url&gt; &lt;branch&gt;</tt></pre>
954 </div></div>
955 <div class="paragraph"><p>In that case, <em>git pull</em> can do the fetch and merge in one go, as
956 follows.</p></div>
957 <div class="exampleblock">
958 <div class="title">Recipe: Push/pull: Merging remote topics</div>
959 <div class="exampleblock-content">
960 <div class="paragraph"><p><tt>git pull &lt;url&gt; &lt;branch&gt;</tt></p></div>
961 </div></div>
962 <div class="paragraph"><p>Occasionally, the maintainer may get merge conflicts when he tries to
963 pull changes from downstream. In this case, he can ask downstream to
964 do the merge and resolve the conflicts themselves (perhaps they will
965 know better how to resolve them). It is one of the rare cases where
966 downstream <em>should</em> merge from upstream.</p></div>
967 <h3 id="_patch_workflow">Patch workflow</h3><div style="clear:left"></div>
968 <div class="paragraph"><p>If you are a contributor that sends changes upstream in the form of
969 emails, you should use topic branches as usual (see above). Then use
970 <a href="git-format-patch.html">git-format-patch(1)</a> to generate the corresponding emails
971 (highly recommended over manually formatting them because it makes the
972 maintainer&#8217;s life easier).</p></div>
973 <div class="exampleblock">
974 <div class="title">Recipe: format-patch/am: Publishing branches/topics</div>
975 <div class="exampleblock-content">
976 <div class="ulist"><ul>
977 <li>
979 <tt>git format-patch -M upstream..topic</tt> to turn them into preformatted
980 patch files
981 </p>
982 </li>
983 <li>
985 <tt>git send-email --to=&lt;recipient&gt; &lt;patches&gt;</tt>
986 </p>
987 </li>
988 </ul></div>
989 </div></div>
990 <div class="paragraph"><p>See the <a href="git-format-patch.html">git-format-patch(1)</a> and <a href="git-send-email.html">git-send-email(1)</a>
991 manpages for further usage notes.</p></div>
992 <div class="paragraph"><p>If the maintainer tells you that your patch no longer applies to the
993 current upstream, you will have to rebase your topic (you cannot use a
994 merge because you cannot format-patch merges):</p></div>
995 <div class="exampleblock">
996 <div class="title">Recipe: format-patch/am: Keeping topics up to date</div>
997 <div class="exampleblock-content">
998 <div class="paragraph"><p><tt>git pull --rebase &lt;url&gt; &lt;branch&gt;</tt></p></div>
999 </div></div>
1000 <div class="paragraph"><p>You can then fix the conflicts during the rebase. Presumably you have
1001 not published your topic other than by mail, so rebasing it is not a
1002 problem.</p></div>
1003 <div class="paragraph"><p>If you receive such a patch series (as maintainer, or perhaps as a
1004 reader of the mailing list it was sent to), save the mails to files,
1005 create a new topic branch and use <em>git am</em> to import the commits:</p></div>
1006 <div class="exampleblock">
1007 <div class="title">Recipe: format-patch/am: Importing patches</div>
1008 <div class="exampleblock-content">
1009 <div class="paragraph"><p><tt>git am &lt; patch</tt></p></div>
1010 </div></div>
1011 <div class="paragraph"><p>One feature worth pointing out is the three-way merge, which can help
1012 if you get conflicts: <tt>git am -3</tt> will use index information contained
1013 in patches to figure out the merge base. See <a href="git-am.html">git-am(1)</a> for
1014 other options.</p></div>
1015 </div>
1016 <h2 id="_see_also">SEE ALSO</h2>
1017 <div class="sectionbody">
1018 <div class="paragraph"><p><a href="gittutorial.html">gittutorial(7)</a>,
1019 <a href="git-push.html">git-push(1)</a>,
1020 <a href="git-pull.html">git-pull(1)</a>,
1021 <a href="git-merge.html">git-merge(1)</a>,
1022 <a href="git-rebase.html">git-rebase(1)</a>,
1023 <a href="git-format-patch.html">git-format-patch(1)</a>,
1024 <a href="git-send-email.html">git-send-email(1)</a>,
1025 <a href="git-am.html">git-am(1)</a></p></div>
1026 </div>
1027 <h2 id="_git">GIT</h2>
1028 <div class="sectionbody">
1029 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite.</p></div>
1030 </div>
1031 </div>
1032 <div id="footnotes"><hr /></div>
1033 <div id="footer">
1034 <div id="footer-text">
1035 Last updated 2011-09-21 23:01:14 PDT
1036 </div>
1037 </div>
1038 </body>
1039 </html>