Kohan95 Kohan95 - 3 months ago 10
Git Question

How to ignore certain files in git?

I have a repository with a file

Hello.java
. When I compile it an additional
Hello.class
file is generated.

I created an entry for
Hello.class
in a
.gitignore
file. However the file still appears to be tracked.

I want to know how to make git ignore
Hello.class
.

Answer

The problem is that .gitignore ignores just files that weren't tracked before (by git add). Run git rm --cached name_of_file and your file will be ignored again (in case it's mentioned in .gitignore).

Comments