Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I untrack files in Git according to my .gitignore file?

Tags:

git

gitignore

I have tracked many many files early, but I don't want Git to track them any more from now on.

Can I untrack those files according to a .gitignore file?

There are too many files and they are separated in many different directories, so it is not practical to remove them one-by-one, instead, I hope they can be untracked according to patterns in a .gitignore file.

like image 967
Yishu Fang Avatar asked Dec 30 '13 13:12

Yishu Fang


1 Answers

You need to remove the files from the index.

git rm -r --cached . 

and then add

git add .

Finally commit:

git commit -a -m "Untrack ignored files!"
like image 174
devnull Avatar answered Sep 23 '22 15:09

devnull