title: Git Workflows: Rebasing Published/Shared Branches
body: <p>Our team at work has enthusiastically adopted a rebase workflow, but we might have gotten a little carried away, which is the point of this question: you be the judge.</p>
  
  <p>Using pull --rebase is a no-brainer to me now.  However, we also have large feature branches that multiple people work on.  Periodically, we want to bring in changes that are happening on master.  Conventional wisdom would have us merge since it's a shared branch.  However, in our rebase-obsession, we've decided to rebase those branches.  Of course that requires everyone's cooperation.  The workflow goes something like this:</p>
  
  <p>1) The rebaser coordinates with everyone to make sure they're all checked-in and pushed on the feature branch, then asks them to do no more work on that branch until they get the all clear.</p>
  
  <p>2) The rebaser rebases the feature branch onto master, deletes the remote feature branch (git push origin :feature), and then pushes the new, rebased feature branch (git push origin feature)</p>
  
  <p>3) The rebaser has everyone fetch, which updates their feature branch, then delete their local feature branch (git branch -D feature), then create a new local feature branch that tracks the remote feature branch.  Everyone then gets the all-clear.</p>
  
  <p>This workflow is working, partially because we're a small group, and the work interruptions are small.  However, I worry that we're learning poor Git habits (rebasing a shared branch), or that the workflow won't scale well.</p>
  
  <p>On the upside, our repository history is lovely.</p>
  
  <p>What do you think, Git gurus?  Are we playing with fire, or rocking a reasonable workflow?</p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>It's two years since I originally asked the question, and my has our workflow changed since then.  We still routinely do <code>git pull --rebase</code>, so that hasn't changed.  It's common sense, and it prevents all the unsightly, confusing mini-merges.  (We keep mostly in sync, so there's little cost to <code>git pull --rebase</code>).</p>
  
  <p>Other than that, however, and the occasional heroic action to correct a mistake, we are over our rebase madness.  Merging makes sense most of the time.  However, wanton merging is problematic, and does contribute to the confusing, chaotic history I was concerned about two years ago.</p>
  
  <p>Our solution has several components:</p>
  
  <ul>
  <li><p>The master branch is "pristine".  Topic branches get merged in, and <em>once they do, the topic branch is retired</em>.  In other words, merging a topic branch in signifies that that work is ready for production, and is now part of the master branch.  Looking at our version history, it's very clear what's happening: topic branches getting merged into master, and that's that.</p></li>
  <li><p>We use disposable integration branches when necessary.  For example, if we have topic branches A, B, and C, and none of them are ready for integration into master, but we need to test them together, we just create a QA branch (usually off of master), and then merge A, B, and C in.  At some point, the QA branch is deleted or re-used.  The point is that it's not intended to be permanent in any way, and it doesn't have the same restrictions as the master branch (you can merge in your topic branches as many times as you want).  If the history gets too confusing, you can just delete the QA branch and start fresh (an approach we have found to be very natural).</p></li>
  <li><p>When merging, <strong>always</strong> use <code>git merge --no-ff</code>.  This is such a tremendous reversal from our "linear commit history" obsession from two years ago that it deserves comment.  Now that we've relaxed about a linear commit history, and seen that merges are good and useful, we've started to <em>rely</em> on topic branches being <em>actual branches</em> off of master, not just a series of commits that eventually becomes one with master.  <code>git merge --no-ff</code> ensures there's always a merge commit, even when it's not necessary.</p></li>
  <li><p>We have a well-understood convention for commit messages and branches and, more importantly, <strong>it cross-references our issue-tracking system</strong>.  Our issue tracking system uses numeric issue numbers, and for any feature (or defect), we have an issue number (1234, for example).  If you're working on that issue, you would create a branch <code>_1234</code> and start every commit message with <code>"_1234: doing blah blah"</code>.  It may seem a little obsessive, but it has really worked well for us, and significantly reduced/eliminated confusion.</p></li>
  <li><p>Use a git wrapper to encourage workflow adhesion.  This is something we're currently working on, but we've realized is entirely necessary to prevent simple and understandable mistakes, like branching off of the wrong thing (we recently had a complete disaster when a developer created a topic branch off of a disposable QA branch: that topic branch was approved to go live, it was merged in...and a bunch of changers that <em>weren't</em> approved to go live were sucked in).  Our git wrapper will require confirmation whenever you do something unusual (like creating a branch off of anything but master, creating a branch not named _NNNN, making a commit that doesn't start with _NNNN, etc.).  Occasionally, we do need to do these things, so the wrapper doesn't <em>prevent</em> it, but it does keep people from accidentally doing something they shouldn't.</p></li>
  </ul>