si acabas de agregar un archivo y ya esta agregado a stagin pero lo agregaste al .gitignore con este comando lo elimnas
#Remove everything from the index
git rm -r --cached .
#Re add everyting
git add .
# Commit
git commit -m 'Remove all files that are in the ignore file'