How to exclude R.java from Git tracking (after the fact)?

It seemed to me that I was very familiar with how to use .gitignore (which is still great for excluding top-level directories), but now I found that several R.java files from different libraries used in my application, and I would like to stop tracking them.

I tried adding the R.java line in .gitignore to the top level directory, but git status continues to report changes.

Then I tried to add the */gen/ in .gitignore to the top level directory, but git status is still reporting changes.

What is the trick to tell git to stop tracking them?

+6
source share
2 answers

.gitignore should prevent indexing. Did you delete junk files with git rm or rm ?

+4
source

You need to remove them from repo first ( git rm or git rm --cached and commit) in order to ignore the operation, since git does not ignore tracking / version files.

+4
source

Source: https://habr.com/ru/post/894928/


All Articles