Respect .gitignore after files that should be ignored are already commited

If you add files or folders to the .gitignore file, the files will be ignored from commits. If you already added and commited the files, that should be ignored, in the past, the files will not be ignored!

If you want to fix that, you have to add the files and folders, that should be ignored, to the .gitignore file.

Next, you have to remove everything from the index:

git rm -r --cached .

Your current work files won’t be deleted. The next step is to add all files again:

git add .

Now, your gitignore is used to ignore the desired files and folders.

Last step is to commit everything:

git commit -m ".gitignore is now correctly ignoring all files and folders"

Now, everything should be fine.