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">
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">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.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
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.0em;
131 div
.content
{ /* Block element content. */
135 /* Block element titles. */
136 div
.title
, caption
.title
{
138 font-family: sans-serif
;
142 margin-bottom: 0.5em;
148 td div
.title:first-child
{
151 div
.content div
.title:first-child
{
154 div
.content
+ div
.title
{
158 div
.sidebarblock
> div
.content
{
160 border: 1px solid silver
;
164 div
.listingblock
> div
.content
{
165 border: 1px solid silver
;
170 div
.quoteblock
, div
.verseblock
{
174 border-left: 5px solid
#dddddd;
178 div
.quoteblock
> div
.attribution
{
183 div
.verseblock
> div
.content
{
186 div
.verseblock
> div
.attribution
{
190 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
191 div
.verseblock
+ div
.attribution
{
195 div
.admonitionblock
.icon
{
199 text-decoration: underline
;
201 padding-right: 0.5em;
203 div
.admonitionblock td
.content
{
205 border-left: 3px solid
#dddddd;
208 div
.exampleblock
> div
.content
{
209 border-left: 3px solid
#dddddd;
213 div
.imageblock div
.content
{ padding-left: 0; }
214 span
.image img
{ border-style: none
; }
215 a
.image:visited
{ color: white
; }
219 margin-bottom: 0.8em;
232 list-style-position: outside
;
235 list-style-type: decimal
;
238 list-style-type: lower-alpha
;
241 list-style-type: upper-alpha
;
244 list-style-type: lower-roman
;
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
{
254 margin-bottom: 0.1em;
257 div
.tableblock
> table
{
258 border: 3px solid
#527bbd;
260 thead
, p
.table
.header
{
261 font-family: sans-serif
;
273 /* Because the table frame attribute is overriden by CSS in most browsers. */
274 div
.tableblock
> table
[frame
="void"] {
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
;
289 margin-bottom: 0.8em;
292 padding-bottom: 15px;
294 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
300 padding-right: 0.8em;
306 div
.hdlist
.compact tr
{
315 .footnote, .footnoteref {
319 span
.footnote
, span
.footnoteref
{
320 vertical-align: super
;
324 margin: 20px 0 20px 0;
328 #footnotes div
.footnote
{
334 border-top: 1px solid silver
;
344 div#footer-badges
{ display: none
; }
348 margin-bottom: 2.5em;
353 font-family: sans-serif
;
357 margin-bottom: 0.1em;
360 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
376 /* Overrides for manpage documents */
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver
;
381 border-bottom: 2px solid silver
;
391 div#toc
{ display: none
; }
394 /* Workarounds for IE6's broken and incomplete CSS2. */
396 div
.sidebar-content
{
398 border: 1px solid silver
;
401 div
.sidebar-title
, div
.image-title
{
403 font-family: sans-serif
;
406 margin-bottom: 0.5em;
409 div
.listingblock div
.content
{
410 border: 1px solid silver
;
415 div
.quoteblock-attribution
{
420 div
.verseblock-content
{
423 div
.verseblock-attribution
{
428 div
.exampleblock-content
{
429 border-left: 3px solid
#dddddd;
433 /* IE6 sets dynamically generated links as visited. */
434 div#toc
a:visited
{ color: blue
; }
436 <script type=
"text/javascript">
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
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 */
459 toc: function (toclevels
) {
461 function getText(el
) {
463 for (var i
= el
.firstChild
; i
!= null; i
= i
.nextSibling
) {
464 if (i
.nodeType
== 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
466 else if (i
.firstChild
!= null)
472 function TocEntry(el
, text
, toclevel
) {
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
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);
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");
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");
532 for (i
=0; i
<spans
.length
; i
++) {
533 if (spans
[i
].className
== "footnote") {
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>";
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
;
550 noteholder
.parentNode
.removeChild(noteholder
);
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.
559 "[<a href='#_footnote_" + n
+
560 "' title='View footnote' class='footnote'>" + n
+ "</a>]";
573 gitworkflows(
7) Manual Page
576 <div class=
"sectionbody">
578 An overview of recommended workflows with git
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">
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>
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
’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>
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>
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;
648 <em>master
</em> tracks the commits that should go into the next release;
653 <em>next
</em> is intended as a testing branch for topics being tested for
654 stability for master.
658 <div class=
"paragraph"><p>There is a fourth official branch that is used slightly differently:
</p></div>
659 <div class=
"ulist"><ul>
662 <em>pu
</em> (proposed updates) is an integration branch for things that are
663 not quite ready for inclusion yet (see
"Integration Branches"
668 <div class=
"paragraph"><p>Each of the four branches is usually a direct descendant of the one
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
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,
…). Fork it off
704 at the oldest integration branch that you will eventually want to merge it
707 <div class=
"paragraph"><p>Many things can then be done very naturally:
</p></div>
708 <div class=
"ulist"><ul>
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
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.)
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>.
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
 — and by extension,
738 merging anything upstream into anything downstream on a regular basis
 — 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>
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>
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>
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>
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>
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>
825 <tt>git checkout maint
</tt>
830 <tt>git merge --ff-only master
</tt>
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>
849 <tt>git checkout next
</tt>
854 <tt>git reset --hard master
</tt>
859 <tt>git merge ai/topic_in_next1
</tt>
864 <tt>git merge ai/topic_in_next2
</tt>
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
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>
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
’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>
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;
916 <a href=
"git-fetch.html">git-fetch(
1)
</a> that copies remote branches to your repository;
922 <a href=
"git-pull.html">git-pull(
1)
</a> that does fetch and merge in one go.
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
<remote
> <branch
></tt> and tell everyone where they can fetch
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
<remote
></tt> or
<tt>git remote update
</tt> to stay up to date.
</p></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
’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 <url
> <branch
></tt></pre>
955 <div class=
"paragraph"><p>In that case,
<em>git pull
</em> can do the fetch and merge in one go, as
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
<url
> <branch
></tt></p></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
’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>
979 <tt>git format-patch -M upstream..topic
</tt> to turn them into preformatted
985 <tt>git send-email --to=
<recipient
> <patches
></tt>
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
<url
> <branch
></tt></p></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
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
< patch
</tt></p></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>
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>
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>
1032 <div id=
"footnotes"><hr /></div>
1034 <div id=
"footer-text">
1035 Last updated
2011-
09-
21 23:
01:
14 PDT