Preserve the project's .gitignore so that we don't check in or otherwise screw up hidden files
Do a fetch from the target remote to see if it was created remotely
Does it exist remotely?
Preserve ignored files, but make sure they're actually ignored!
We want to keep in complete sync (deleting old docs, or cruft from previous documentation output)
The previous solution below fails to copy .dot-files, therefore we utilize
find, which in turn also made the if-statement obsolete.
cp -Rf $DOCS_PATH/* . if [[ -e $DOCS_PATH/.gitignore ]]; then cp $DOCS_PATH/.gitignore .gitignore fi
Alternative solution using tar
( cd $DOCS_PATH ; tar --excude .git cf - . ) | tar xkpvvf -
Do nothing unless we actually have changes
Clean up after ourselves
Git spits out status information on $stderr, and we don't want to relay that as an error to the user. So we wrap git and do error handling ourselves...