How to ignore certain files in Git


I have a repository with a file, 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.

How can I make Git ignore Hello.class?


The problem is that .gitignore ignores just files that weren't tracked before (by git add). Run git reset name_of_file to unstage the file and keep it. In case you want to also remove the given file from the repository (after pushing), use git rm --cached name_of_file.

How can I have multiple working directories with Git?

Git is not working after macOS update ("xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools")