title: Remove folder and its contents from git/GitHub's history
body: <p>I was working on a repository on my GitHub account and this is a problem I stumbled upon.</p>
  
  <ul>
  <li>Node.js project with a folder with a few npm packages installed</li>
  <li>The packages were in <code>node_modules</code> folder</li>
  <li>Added that folder to git repository and pushed the code to github (wasn't thinking about the npm part at that time)</li>
  <li>Realized that you don't really need that folder to be a part of the code</li>
  <li>Deleted that folder, pushed it </li>
  </ul>
  
  <p>At that instance, the size of the total git repo was around <strong>6MB</strong> where the actual code (all except that folder) was only around <strong>300 KB</strong>. </p>
  
  <p>Now what I am looking for in the end is a way to get rid of details of that package folder from git's history so if someone clones it, they don't have to download 6mb worth of history where the only actual files they will be getting as of the last commit would be 300KB.</p>
  
  <p>I looked up possible solutions for this and tried these 2 methods</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/2164581/remove-file-from-git-repository-history">Remove file from git repository (history)</a></li>
  <li><a href="http://help.github.com/remove-sensitive-data/" rel="noreferrer">http://help.github.com/remove-sensitive-data/</a></li>
  <li><a href="https://gist.github.com/1588371" rel="noreferrer">https://gist.github.com/1588371</a></li>
  </ul>
  
  <p>The Gist seemed like it worked where after running the script, it showed that it got rid of that folder and after that it showed that 50 different commits were modified. But it didn't let me push that code. When I tried to push it, it said <code>Branch up to date</code> but showed 50 commits were modified upon a <code>git status</code>. The other 2 methods didn't help either.</p>
  
  <p>Now even though it showed that it got rid of that folder's history, when I checked the size of that repo on my localhost, it was still around 6MB. (I also deleted the <code>refs/original</code>folder but didn't see the change in the size of the repo).</p>
  
  <p>What I am looking to clarify is, if there's a way to get rid of not only the commit history (which is the only thing I think happened) but also those files git is keeping assuming one wants to rollback.</p>
  
  <p>Lets say a solution is presented for this and is applied on my localhost but cant be reproduced to that GitHub repo, is it possible to clone that repo, rollback to the first commit perform the trick and push it (or does that mean that git will still have a history of all those commits? - aka. 6MB). </p>
  
  <p>My end goal here is to basically find the best way to get rid of the folder contents from git so that a user doesn't have to download 6MB worth of stuff and still possibly have the other commits that never touched the modules folder (that's pretty much all of them) in git's history.</p>
  
  <p>How can I do this?</p>