Factor-out git_(add/commit)_with_retry.
Handle git errors during .gitignore creation.
Re-indent for consistency.