Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

Folders to make sure are included in .gitignore

+14 votes
Because we have been having a bit of trouble with .gitignore and pushing/pulling from github, should we tell .gitignore to ignore all folders that do not contain files that we are editing?  So, for example, ignore everything except for the folder with the .java and .class files?
asked Oct 5, 2015 in Fall 15-16 by Nick Caputo (100 points)
Wait, why not refrain from adding the files before committing? If I understand correctly.
Pretty sure this is the most legit solution, but if you're doing it in Netbeans/Eclipse, it's easy to accidentally add/commit the whole project. They make it very easy for you. Too easy.

1 Answer

+1 vote
I don't know about Netbeans but Eclipse has an Ignore option.

 

If you right-click on the file that you wish to ignore and go to Team>Ignore it should remove it from Index and keep it from adding back to the index if a folder containing the ignored file is added to index.

 

Also if you wish to ignore certain file paths in general, you can go to Window>Preferences

This will bring up the Preferences dialogue box. In that go to Team>Ignored Resources

Now you can check all the file path extensions that you want to ignore.
answered Oct 26, 2015 by Luke Currie (100 points)
Adding that Netbeans does have an Ignore under Team or Git. But this isn't what he was asking--he wanted to know if there were sections of the whole project folder that should have been ignored, and if so, what they would be--not how to do it. As it turns out, not only did we have a bunch of stuff left out of .gitignore that should have been in there, but we needed to actually actively untrack a bunch of stuff separately.
...