# Untrack files already added to git repository based on .gitignore

# 1. Commit all your changes
# Including updated .gitignore file

# 2. Remove everything from the repository
git rm -r --cached .

# 3. Re add everything
git add .

# 4. Commit 
git commit -m ".gitignore fix"

Ref