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.
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 to ignore new files
Globally
Add the path(s) to your file(s) which you would like to ignore to your .gitignore file (and commit them). These file entries will also apply to others checking out the repository.
Locally
Add the path(s) to your file(s) which you would like to ignore to your .git/info/exclude file. These file entries will only apply to your local working copy.
How to ignore changed files (temporarily)
In order to ignore changed files to being listed as modified, you can use the following git command:
git update-index --assume-unchanged <file1> <file2> <file3> To revert that ignorance use the following command:
git update-index --no-assume-unchanged <file1> <file2> <file3>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With