title: When pinned to a git branch, how exactly does npm's cache work?
body: <p>We're running into a really interesting edge-case that I thought I would post about, see if anyone can shed some light towards.</p>
  
  <p>We have a project that is pinned to an npm module via git repo url:</p>
  
  <pre><code>dependencies: {
    "whatever": "git+ssh://whatever@whatever.com/whatever#bugfix/foo"
  }
  </code></pre>
  
  <p>We have two branches out on origin:</p>
  
  <pre><code>bugfix/foo
  bugfix/updated-foo
  </code></pre>
  
  <p>The second branch, <code>bugfix/updated-foo</code> was rebased off of <code>bugfix/foo</code> on the second to last commit of <code>bugfix/foo</code>.</p>
  
  <p>In both branches, the <code>version</code> in <code>package.json</code> is set to <code>5.0.2</code> as they were both branched from <code>master</code>. Our latest release is <code>5.0.2</code>.</p>
  
  <p>Finally, my question: <strong>Does npm cache modules based upon the <code>version</code> specified in <code>package.json</code>?</strong> The behavior we're seeing is that sometimes one branch will be checked out upon building the project, other times the other.</p>
  
  <p>This has got us all kind of confused as we made the assumption that the branch name was used as the unique identifier in this scenario.</p>
  
  <p>Thank you!</p>