You will have to clear the existing git cache
first.
Remove the cache of all the files
git rm -r --cached .
Remove the cache of specific file
git rm -r --cached <file_name.ext>
Once you clear the existing cache, add/stage file/files in the current directory and commit
git add .
// To add all the filesgit add <file_name.ext>
// To add specific filegit commit -m "Suitable Message"
As pointed out by Scott Biggs in comment that “This works for both adding a file that was once ignored as well as ignoring a file that was once tracked”