I had to create git ignore files for our project, and it took me more than my expectation. First of all, ** does not work with directories. Second of all, I had an idea to have only one ignore file with plenty of relative paths (not full but using * or ** ) but eventually it failed in my case. Thus I distributed files into subfolders where projects are generated and libraries are built.
This post made it clear and ever since it was simple to exclude specific files in particular directories
Git ignore specific files in directories [stackoverflow.com]
I have something like
!/*/build/iar/
/*/build/iar/*
!/*/build/iar/config files
!/*/build/iar/*.ewp
!/*/build/iar/*.ewd
!/*/build/iar/*.eww
One more tip, I have googled a bit when I faced a problem with git, and usually I landed at git ready webpage. This is excellent git reference.
git ready [gitready.com]