If the file or folder you try to ignore is already tracked by the git, then you have to remove it from the tracking.
To remove the file from tracking, run the following command.
git rm <your-file-name-with-extension> --cached
To removed the folder from tracking, run the following command.
git rm <your-folder-name> --cached -r
Here, -r
represent recursive.