When you add/modify the .gitignore file and then try to commit the changes, you will see that the files you asked git to ignore are still on the HEAD, they are still there, this is because you need to tell git to remove them from the index.
The way to “fix” .gitignore file is after making in a .gitignore file, not matter if you working with BitBucket, GitHub, or any other service, to fix the issue you need to execute these commands:
git rm -rf --cached . git add . git commit -m 'fixed gitignore'
git rm -r --caced – will remove the files completely from the index (just like add is adding to the index).
git add . – will add all of the files (this is the dot, dot means all).
git commit -m 'fixed gitignore' – will commit the the changes with the label of: “fixed gitignore”, this can be whatever you want, for me, each time I start a project and do the first commit, I ALWAYS forget to add/change/create the .gitignore file, so my two first commits are always: ‘inital commit’ and ‘fixed .gitignore’.