title: Git: Merging and Submodules
body: <p>Lets say I have two branches in RepoX called BranchA and BranchB. RepoX also has a submodule called SubmoduleY.</p>
  
  <p>BranchA has SubmoduleY at revision 'abc', BranchB has SubmoduleY at revision 'def'.</p>
  
  <p>Say I want to merge BranchA into BranchB, but I want to leave BranchB's SubmoduleY pointing to its original revision of 'def'. I see a couple ways of doing this:</p>
  
  <p>Method 1:</p>
  
  <ol>
  <li>Checkout BranchB.</li>
  <li>Move SubmoduleY to revision 'abc' to make the actual merge painless (we don't want to do any merging at the submodule level right now). </li>
  <li>Commit the new revision for SubmoduleY (we can't have it floating for the merge).</li>
  <li>Merge BranchA into BranchB. Resolve any conflicts.</li>
  <li>Move SubmoduleY back to revision 'def'.</li>
  <li>Commit the new revision for SubmoduleY.</li>
  <li>Push changes up to the main repo.</li>
  </ol>
  
  <p>Method 2: </p>
  
  <p>Same as method 1, but instead of doing step 6, rebase and get rid of the extra submodule commit from step 3.</p>
  
  <p>Both seem to have annoying drawbacks:</p>
  
  <p>Method 1 puts two extra commits into history.</p>
  
  <p>Method 2 forgets any changes to do with submodule revisions because those commits get removed. Therefore, any merges later on will have to deal with some problems again.</p>
  
  <p>Is there a better way?</p>