Removes a file from the git cache so .gitignore kicks in.
List of .gitignore starter files https://github.com/github/gitignore
Git features a ‘remove’ command, git rm. You can use it to remove files from git’s tracking cache, like so: git rm --cached <filename> 1 git rm --cached <filename> The above command is for a specific file. It will take effect with your next commit. It’s a good idea for you to commit any pending changes you have before you start this process. If you have many files and/or folders (for instance, your /bin and /obj folders in a .NET project) that you need to clean up from your repository, you can use the following commands to remove them from the index (cache): git rm -r --cached . 1 git rm -r --cached . The -r switch makes the command recursive from the current path. Next, add back all of the files you do want to track, using: git add . 1 git add . Then, commit your changes and your files that would have been ignored if you’d had the right .gitignore in place from the start should no longer be tracked. Yay! If you’re interested, or if this approach doesn’t work for you, there are a few variations on how you might achieve the same result listed in this StackOverflow thread.