How not to display the .class in git

Rodel Sarate picture Rodel Sarate · Jan 10, 2013 · Viewed 43.7k times · Source

I don't want to display .class files when executing git status.

I created a file named .gitignore and entered the .class in the file but nothing happened.

What is the best way to prevent the .class file from being displayed when you execute git status command?

Answer

VonC picture VonC · Jan 10, 2013

Make sure your .class files were not already added to the index.
You would need to git rm -r --cached path/to/.classfiles/ those files first.
(they will still be on the disk, but no longer part of the git index, and will be ignored by the git status)

If you don't want any .class file versioned (but you didn't include them in the .gitignore initially), as Michal Stefanow comments below:

git rm -r --cached *.class

Mark adds in the comments:

For Windows TortoiseGit users like me, follow the instructions in this related post to do the git in the GUI

Right click that file, choose TortoiseGit -> Delete (keep local).
This does git rm --cached.