I think the problem here is that you exclude the complete node_modules folder AFTER you excluded some files, which might overwrite your previous inclusions/exclusion. That means in the beginning you say you want to include and exclude some files in the node_modules folder, but later on you just tell git "well, nevermind, just ignore the whole folder". So turning the order around might be a good step to start with.
But we're probably not finished. Also when you exclude a whole folder instead of files, git won't be able to find any files inside that if you want to exclude them. Let's just assume you ignored the folder node_modules, but want to exclude some files inside of it after that. It probably won't work because there is no folder to check for those files anymore. This folder is actually ignored.
So what you could try was to ignore all the files in the folder instead and then make some exclusions of those files.
# ignore all files in the folder
node_modules/**/*
# but not those files
!node_modules/angularfire/dist/angularfire.js
!node_modules/todomvc-app-css/index.css
!node_modules/todomvc-common/base.css
!node_modules/todomvc-common/base.js
Hope this works.