Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

gitignore

I thought that I was pretty familiar with how to use .gitignore (which still works great for me for excluding top level directories), but I now discovered that multiple R.java files from various libraries used in my application are being tracked and I would like to stop tracking them.

I tried adding the line R.java to the .gitignore in the top level directory, but git status keeps reporting them as modified.

I then tried adding the line */gen/ to the .gitignore in the top level directory, but git status still reports them as modified.

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

like image 882
an00b Avatar asked Aug 12 '11 17:08

an00b


2 Answers

.gitignore should stop them from being indexed. Did you delete the unwanted files with git rm or rm?

like image 158
atamanroman Avatar answered Sep 28 '22 02:09

atamanroman


You need to first remove them from the repo ( git rm or git rm --cached and commit) for the ignore to work as git does not ignore tracked / versioned files.

like image 34
manojlds Avatar answered Sep 28 '22 02:09

manojlds