1.  i.e., stop tracking the file but not delete it from your system use:

    git rm --cached filename
    CODE
  2. First commit any outstanding code changes, and then, run this command:

    git rm -r --cached .
    CODE
  3. To untrack every file that is now in your .gitignore

 

Ref