Reputation: 2113
I am still new to git. Since I do not need my repository to be publicly available, I chose Bitbucket. As my desktop client I use Atlassian Sourcetree.
I am working on a Java project using Eclipse IDE. Just like everyone, I do not need the class files to be visible in changed files, however those files have already been committed and pulled into my remote repository.
Now I need SourceTree to not to show those class files as changed files whenever I make a change to .java
file.
As I have understood by coming through so many questions and answers, the entry in the .gitignore
file alone cannot simply ignore the class files since they have already been committed and pulled.
For that, as I understand, what I should do is ignore the file in source tree and commit it. Then only the entry in the .gitignore
file would do what we need. (This is my understanding. Please correct me if I am wrong).
What my problem now is, the ignore
option is grayed out; so as a solution for that the community suggest to first select the Stop Tracking
option and then select the ignore
option. But when I do Stop Tracking, no change appears.
As per the community, the file should be marked with a blue icon. But it is not in my case. Even though I didn't get change of the icon, I then tried to select the ignore option. But still it is grayed out. Even after doing these steps, when I make a change to .java
file, the .class
file appears in the changed files list.
What is wrong here? Why I am not getting the job done? What have I done wrong?
Upvotes: 2
Views: 6394
Reputation: 21
Enter git status to display your modified code changes.then add your unwanted files in the .gitignore . At last add your file and commit it.
Upvotes: 0
Reputation: 1323993
What my problem now is, the ignore option is grayed out; so as a solution for that the community suggest to first select the Stop Tracking option and then select the ignore option.
According to "What is the difference between Stop Tracking and Discard File in git SourceTree":
You should use
Stop Tracking
.
After this, if you see the file listed in Unstaged files, you can useright-click > Ignore...
in SourceTree to update your.gitignore
file to ignore the file in future.
In your case though, instead of adding the files one by one to a .gitignore
, adit a .gitignore
at the root of your repo and add:
*.class
Upvotes: 2