If the files were already committed to the git, you have to make a commit that deletes the files before .gitignore takes effect for those files
.gitignore