Letter A, logo

Git unfollow. Forget some files.

Icon calendar

April 2021

Icon calendar

1 min

What happens when you are tracking a file or a folder on your git repository, but you no longer want to? Or maybe you even added it by accident or forgot to add it to your .gitignore file? You can start by adding it to your .gitignore file, but this won't stop git to keep track of it because it's already on the repo. To stop the tracking you ned to remove it from the index.

For a file:

git rm --cached <file-name.extension>

For a folder:

git rm -r --cached <folder-name>
  • rm: remove command
  • -r: recursive (recursive removal in this case)
  • --cache: will remove the file/folder from the index

That will do it! Just remember that this won't remove the file on your computer, but it will in a different computer when you retrieve the files from the repo by git pull.

Icon tag git Icon tag nugget
Twitter iconTweet me about this!