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
.
You should write something like
into your
.gitignore
file.Add the following line to .gitignore:
This will exclude Hello.class from git. If you have already committed it, run the following command:
If you want to exclude all class files from git, add the following line to .gitignore:
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 repo.
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:
To revert that ignorance use the following command:
By creating a .gitignore file. See here for details: Git Book - Ignoring files
Also check this one out: How do you make Git ignore files without using .gitignore?
I had a similar issue with file "dump.rdb".
I tried adding this file in various ways to .gitignore file, but only one way worked.
NOTE: Adding the file anywhere else didn't work.
For example, see: https://gitlab.com/gitlab-org/gitlab-ce/raw/b3ad3f202478dd88a3cfe4461703bc3df1019f90/.gitignore
Create a
.gitignore
in the directory where .git is. You can list files in it separated by a newline. You also can use wildcards: