How to prevent "drush up" from destroying my git repo
The deletion of the .git directory and other non-Drupal files when running drush up drupal has been a somewhat randomly occurring problem for many Drush users as documented on this GitHub issue. As far as I know, no definitive reason for this behavior has been found, and there is even debate about whether this behavior is, or should be, by design.

In my experience and that of others participating in the GitHub discussion, this deletion of the .git directory did not happen when using Drush 6, but happens in some circumstances when using Drush 7 or 8. Therefore, there's no surefire way of avoiding the deletion of the .git directory and other non-Drupal files when running drush up drupal besides moving those files out of the Drupal root directory before running the update.

However, the overwriting of .gitignore when running drush up drupal occurs by design. .gitignore is a core Drupal file, and as Drush warns, updating core will discard any customizations:

Code updates will be made to drupal core.
WARNING:  Updating core will discard any modifications made to Drupal
core files, most noteworthy among these are .htaccess and robots.txt.  If 
you have made any modifications to these files, please back them up 
before updating so that you can re-create your modifications in the 
updated version of the file.


.gitignore isn't mentioned explicitly in that warning, but it is treated similarly since it, too, is a Drupal core file.