title: Specify branch for a git submodule?
body: <p>I have added a git submodule to my git repository and it works fine.</p>
  
  <p>In my "parent" repository I have created a feature branch: <strong>myfeature</strong> that requires some changes to the sub module. But I don't want to affect other teams using the same sub module. Therefore I have created a corresponding feature branch on the submodule repository <strong>submodule-feature</strong> with some changes. I have then added/committet the change from the submodule directory followed by the same in the root of the parent repository.</p>
  
  <p>But when I switch back to <strong>master</strong> on my "parent" repository the submodule is still on the <strong>submodule-feature</strong> feature branch. That is not what I expect. Because now when I run my tests on <strong>master</strong> they fail because I have introduced some breaking changes in the submodule on the <strong>submodule-feature</strong> branch.</p>
  
  <p>Is it not possible to <em>lock</em> the branch of a submodule to the parent repository branch?</p>
  
  <p>EDIT:
  Based on:
  <a href="https://stackoverflow.com/questions/1777854/how-can-i-specify-a-branch-tag-when-adding-a-git-submodule">How can I specify a branch/tag when adding a Git submodule?</a></p>
  
  <p>Looks like I can specify a branch for the sub module repository in <code>.gitmodules</code></p>
  
  <pre><code>[submodule "mysubmodule"]
      path = mysubmodule
      url = https://bla.git
      branch = submodule-feature
  </code></pre>
  
  <p>And adding the following additional git behavior in jenkins:</p>
  
  <p><a href="https://i.stack.imgur.com/kq66d.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kq66d.png" alt="enter image description here"></a></p>
  
  <p>and:</p>
  
  <p><a href="https://i.stack.imgur.com/lJCus.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lJCus.png" alt="enter image description here"></a></p>
  
  <p>it clones/checkout the <code>submodule-feature</code> branch when running a build on the <em>parent</em> <strong>myfeature</strong> branch.</p>
  
  <p>But that will of course require some manual steps when working locally. But from CI side its very easy to accomplish.</p>