How can I ignore everything but *.cpp files?

So I have a file directory that contains many types of files, but I would like to ignore every file except a few and...

Sourcetree adding files in global .gitignore, not in repository .gitignore?

I am using SourceTree for my GIT repositories. Today I need to ignore some files; when I added these files to ignor...