Zequan Wu Zequan Wu - 1 month ago 4x
Git Question

How to untrack added file ending with certain character from git?

I accidentally added all files from my local folder into my git repository. I want to untrack some of files ending with certain symbol, like "~" etc. How can I do this? Since I already added them into the repository, any edit in .gitignore will not untrack already added files.


This is not exactly the same question, so I won't mark as duplicate, but the second answer here should apply.

Quoted answer:

The series of commands below will remove all of the items from the Git Index (not from the working directory or local repo), and then updates the Git Index, while respecting git ignores. PS. Index = Cache


git rm -r --cached . 
git add .


git commit -am "Remove ignored files"