title: What Git branching models work for you?
body: <p>Our company is currently using a simple trunk/release/hotfixes branching model and would like advice on what branching models work best for your company or development process.</p>
  
  <ol>
  <li><p><strong>Workflows / branching models</strong></p>
  
  <p>Below are the three main descriptions of this I have seen, but they are partially contradicting each other or don't go far enough to sort out the subsequent issues we've run into (as described below). Thus our team so far defaults to not so great solutions. Are you doing something better? </p>
  
  <ul>
  <li><a href="http://www.kernel.org/pub/software/scm/git/docs/gitworkflows.html" rel="noreferrer">gitworkflows(7) Manual Page</a> </li>
  <li><a href="http://nvie.com/git-model" rel="noreferrer">(nvie) A successful Git branching model</a></li>
  <li><a href="http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html" rel="noreferrer">(reinh) A Git Workflow for Agile Teams</a></li>
  </ul></li>
  <li><p><strong>Merging vs rebasing (tangled vs sequential history)</strong> </p>
  
  <p>Should one <code>pull --rebase</code> or wait with merging back to the mainline until your task is finished? Personally I lean towards merging since this preserves a visual illustration of on which base a task was started and finished, and I even prefer <code>merge --no-ff</code> for this purpose. It has other drawbacks however. Also many haven't realized the useful property of merging - that it isn't <a href="http://en.wikipedia.org/wiki/Commutativity" rel="noreferrer">commutative</a> (merging a topic branch into master does not mean merging master into the topic branch).</p></li>
  <li><p><strong>I am looking for a natural workflow</strong> </p>
  
  <p>Sometimes mistakes happen because our procedures don't capture a specific situation with simple rules. For example a fix needed for earlier releases should of course be based sufficiently downstream to be possible to merge upstream into all branches necessary (is the usage of these terms clear enough?). However it happens that a fix makes it into the master before the developer realizes it should have been placed further downstream, and if that is already pushed (even worse, merged or something based on it) then the option remaining is cherry-picking, with its associated perils. What simple rules like such do you use? <em>Also in this is included the awkwardness of one topic branch necessarily excluding other topic branches (assuming they are branched from a common baseline). Developers don't want to finish a feature to start another one feeling like the code they just wrote is not there anymore</em></p></li>
  <li><p><strong>How to avoid creating merge conflicts (due to cherry-pick)?</strong> </p>
  
  <p>What seems like a sure way to create a merge conflict is to cherry-pick between branches, they can never be merged again? Would applying the same commit in revert (how to do this?) in either branch possibly solve this situation? This is one reason I do not dare to push for a largely merge-based workflow.</p></li>
  <li><p><strong>How to decompose into topical branches?</strong> </p>
  
  <p>We realize that it would be awesome to assemble a finished integration from topic branches, but often work by our developers is not clearly defined (sometimes as simple as "poking around") and if some code has already gone into a "misc" topic, it can not be taken out of there again, according to the question above? How do you work with defining/approving/graduating/releasing your topic branches?</p></li>
  <li><p><strong>Proper procedures like code review and graduating</strong> would of course be lovely. </p>
  
  <p>But we simply cannot keep things untangled enough to manage this - any suggestions?
  integration branches, illustrations?</p></li>
  </ol>
  
  <p>Below is a list of related questions:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/143814/what-are-some-good-strategies-to-allow-deployed-applications-to-be-hotfixable">What are some good strategies to allow deployed applications to be hotfixable?</a></li>
  <li><a href="https://stackoverflow.com/questions/1049917/workflow-description-for-git-usage-for-in-house-development/1050628">Workflow description for Git usage for in-house development</a></li>
  <li><a href="https://stackoverflow.com/questions/1856241/git-workflow-for-corporate-linux-kernel-development">Git workflow for corporate Linux kernel development</a></li>
  <li><a href="https://stackoverflow.com/questions/216212">How do you maintain development code and production code?</a> (thanks for <a href="https://stackoverflow.com/questions/216212/how-do-you-maintain-development-code-and-production-code/216219#216219">this</a> PDF!)</li>
  <li><a href="https://stackoverflow.com/questions/1042400/git-releases-management">git releases management</a></li>
  <li><a href="https://stackoverflow.com/questions/1241720/git-cherry-pick-vs-merge-workflow">Git Cherry-pick vs Merge Workflow</a></li>
  <li><a href="https://stackoverflow.com/questions/1670970/how-to-cherry-pick-multiple-commits">How to cherry-pick multiple commits</a></li>
  <li><a href="https://stackoverflow.com/questions/449541/how-do-you-merge-selective-files-with-git-merge">How do you merge selective files with git-merge?</a></li>
  <li><a href="https://stackoverflow.com/questions/1994463/how-to-cherry-pick-a-range-of-commits-and-merge-into-another-branch">How to cherry pick a range of commits and merge into another branch</a></li>
  <li><a href="https://stackoverflow.com/questions/855266/reinh-git-workflow">ReinH Git Workflow</a></li>
  <li><a href="https://stackoverflow.com/questions/582015/git-workflow-for-making-modifications-youll-never-push-back-to-origin">git workflow for making modifications you’ll never push back to origin</a></li>
  <li><a href="https://stackoverflow.com/questions/232771/cherry-pick-a-merge">Cherry-pick a merge</a></li>
  <li><a href="https://stackoverflow.com/questions/2195826/proper-git-workflow-for-combined-os-and-private-code">Proper Git workflow for combined OS and Private code?</a></li>
  <li><a href="https://stackoverflow.com/questions/2587721/maintaining-project-with-git">Maintaining Project with Git</a></li>
  <li><a href="https://stackoverflow.com/questions/2588824/why-cant-git-merge-file-changes-with-a-modified-parent-master">Why cant Git merge file changes with a modified parent/master.</a></li>
  <li><a href="https://stackoverflow.com/questions/2601967/git-branching-rebasing-good-practices">Git branching / rebasing good practices</a></li>
  <li><a href="https://stackoverflow.com/questions/2590260/when-will-git-pull-rebase-get-me-in-to-trouble">When will "git pull --rebase" get me in to trouble?</a></li>
  <li><a href="https://stackoverflow.com/questions/787638/how-are-dvcs-used-in-large-teams">How are DVCS used in large teams?</a></li>
  </ul>
  
  <p>Also check out what Plastic SCM writes on <a href="http://www.plasticscm.com/features/task-driven-development.aspx" rel="noreferrer">task driven development</a>, and if Plastic is not your choice, study <a href="http://nvie.com/posts/a-successful-git-branching-model/" rel="noreferrer">nvie's branching model</a> and his <a href="https://github.com/nvie/gitflow" rel="noreferrer">supporting scripts</a>.</p>