Search code examples
gitgitignore

Ignoring files that have already existed with git


If I have a repo with files that were previously not in my .gitignore file that I now want to ignore, how do I do this without deleting the files locally and when you pull from the repo?


Solution

  • git rm --cached somefile will preserve the local copy of the file but make git stop tracking that file. Once you do that, you can add the file to .gitignore too.