Break up .gitignore and use correct syntax.

Paths relative to the top-level checkout directory should start with a
/; those that don't are matched against every sub-directory, not just
the top level.  Moved the large chunks related to docs and tests to
those directories.  Killed some ancient history along the way.

Provoked by discussion with @tzz.
(Pre-existing.)  Well spotted.  Fixed now.