You have to keep in mind that the rules in your .gitignore file only apply to untracked files. Since in your repository the files under that directory were already committed, you need to unstage them first, then create a commit, and push that to GitHub:
$ git rm -r --cached some-directory
$ git commit -m 'Remove the now ignored directory "some-directory"'
$ git push origin master
Note that you won't be able to delete the file from your history without rewriting the history of your repository.
Keep in mind that you should not do this if:
- Anyone else is working with your repository
- You're using it from multiple computers
But if you still want to do that, you can use git filter-branch to rewrite the history.
Here is a guide to that here.
https://help.github.com/en/articles/removing-sensitive-data-from-a-repository