title: How can different branches of a primary repo use different branches of submodule?
body: <p>Suppose that I have a primary repo <code>y</code> with some submodule, say at <code>sub/x</code>.</p>
  <p>Suppose also that, for both the primary and the submodule repos, <code>master</code> is the active branch, and that the <code>.gitmodules</code> file of the primary repo specifies <code>branch = master</code>.</p>
  <p>Now, suppose that, in addition to its <code>master</code> branch, the primary (<code>y</code>) repo has a branch <code>yA</code>, and likewise, in addition to <em>its</em> <code>master</code> branch, the submodule repo (<code>x</code>) has a branch <code>xA</code>.</p>
  <p>I would like the <code>yA</code> branch of the <code>y</code> repo to &quot;see&quot;/use the <code>xA</code> branch of the <code>x</code> repo.</p>
  <p>This would mean that switching between the <code>master</code> and <code>yA</code> branches in the primary repo would cause the corresponding switch between the <code>master</code> and <code>xA</code> branches in the submodule.</p>
  <p>Does git have any support for this?</p>
  <hr />
  <p>I tried the following:</p>
  <ol>
  <li>switched to the <code>yA</code> branch on the primary repo;</li>
  <li>switched to the <code>xA</code> branch on the submodule repo;</li>
  <li>replaced <code>master</code> with <code>xA</code> as the value for the branch parameter in the primary repo's <code>.gitmodules</code> file;</li>
  <li>in the primary repo, committed all the changes resulting from (2) and (3).</li>
  </ol>
  <p>This did not work as I had hoped: if I switch to the <code>master</code> branch on the primary repo, this has no effect on the active branch setting of the submodule repo (and therefore, the <code>master</code> branch does not have a clean status).</p>