This helps untract files previous pushed to repo, and then added to .gitignore
git rm -r --cached .
git add .
git commit -m "chore: untracked files issue resolved to fix .gitignore"
Here is another example un-tracking files like .env and then removing it from the history