If you accidentally committed files on git because you didn’t have a .gitignore file or you just updated it, you can untrack files with:

git rm --cached <file>

or if you have several files:

git rm --cached `git ls-files -i -c --exclude-from=.gitignore`