There are numerous times where we either forgot to remove some unnecessary files but are commited and pushed to master branch in GitHub. In these situation, the following code which I found in StackOverflow helped removing the files from the master branch:
git rm --cached `git ls-files -i --exclude-from=.gitignore`
If you are on windows, you can try:
git ls-files -i -z --exclude-from=.gitignore | xargs -0 git rm --cached
One thing I think is important is to update the .gitignore file before running the code in order to properly work.