title: Node Js, Git, Heroku: Git commits not pushing to git because large file was committed several commits in the past
body: <p><strong><em>See edit below</em></strong></p>
  
  <p>I'm trying to push to git, and then to heroku. However, I think that my push to git is being interupted because of the 'node_modules' folder. </p>
  
  <p>The error I get:
  remote: error: GH001: Large files detected...
  To git@github...git
    ! [remote rejected] master -> master (pre-receive hook declined)
  error: failed to push some refs to 'git@github...git'</p>
  
  <p>The large file is libsass.lib, which is within node_modules.</p>
  
  <p>So I've added node_modules to my .gitignore file just like this:</p>
  
  <pre><code>node_modules/
  </code></pre>
  
  <p>And I've ran this command to remove node modules from the git push:</p>
  
  <pre><code>git rm --cached node_modules
  git add .
  git commit -am "Remove ignored files"
  </code></pre>
  
  <p>It says it works, but then I try and push again and get the same error.</p>
  
  <p>What's my next step? Thanks a lot.</p>
  
  <p><strong>Edit. The duplicate question attached above did not help my problem. Here is what I did that eventually worked as I would expect.</strong></p>
  
  <p>I had 9 commits on my system that would not push, presumably because my first push failed. This will erase things, so backup your files. So I worked backward, removing them using:</p>
  
  <pre><code>git reset --hard HEAD~1 // Destroys the current commit, moving backward by one setp.
  </code></pre>
  
  <p>Once I made it to the start, I created my gitignore file for node_modules. Then I removed it's reference from git:</p>
  
  <pre><code>git rm -r --cached node_modules
  git commit -m "remove node_modules"
  git push origin master
  </code></pre>
  
  <p>My heroku instance was ahead in terms of commit, so I then forced a push to reset.</p>
  
  <pre><code>git push -f heroku
  </code></pre>
  
  <p>Now everything works again.</p>