Remove a file from tracking in git

So you have added a new file to .gitignore or you have just added a new .gitignore file to your existing repo. The problem is same you don’t want git to rack one or many files. This can be archived in simple 3 step process. Assuming that you have already added or updated .gitignore file you need to do following steps

  1. Remove all files from index i.e clear cache
  2. Add all files using add command. This time due to .gitignore only relevent files will be added
  3. Commit
//remove every thing from index
git rm -r --cached .   

//add everything respecting the new/updated .gitignore
git add .

//Commit
git commit -m "We have updated .gitignore or added it"

Hope this helps !!!

A pat on the back !!