title: Git submodules, switching branches, and the recommended way to include external JS dependencies (oh my)
body: <p>I have a Ruby on Rails project (versioned with git) that includes a number of external JavaScript dependencies that exist in various public GitHub repositories. What's the best way to include those dependencies in my repository (aside, of course, from just manually copying them in) in a way that allows me to control when they get updated?</p>
  
  <p>git submodules seem like the perfect way to go, but it causes problems when switching among several branches, many of which don't contain the same submodules.</p>
  
  <p>If git submodules are the best way to do it, I suppose my real question is: How can I use submodules among many branches without running into this problem all the time:</p>
  
  <pre><code>my_project[feature/new_feature√]$ git submodule update 
  Cloning into public/javascripts/vendor/rad_dependency...
  remote: Counting objects: 34, done.
  remote: Compressing objects: 100% (29/29), done.
  remote: Total 34 (delta 9), reused 0 (delta 0)
  Receiving objects: 100% (34/34), 12.21 KiB, done.
  Resolving deltas: 100% (9/9), done.
  Submodule path 'public/javascripts/vendor/rad_dependency': checked out '563b51c385297c40ff01fd2f095efb14dbe736e0'
  
  my_project[feature/new_feature√]$ git checkout develop 
  warning: unable to rmdir public/javascripts/milkshake/lib/cf-exception-notifier-js: Directory not empty
  Switched to branch 'develop'
  
  my_project[develop⚡]$ git status
  # On branch develop
  # Untracked files:
  #   (use "git add &lt;file&gt;..." to include in what will be committed)
  #
  #   public/javascripts/milkshake/lib/cf-exception-notifier-js/
  nothing added to commit but untracked files present (use "git add" to track)
  </code></pre>