I was recently deploying some static content to a Google Storage bucket and noticed that there wasn't an answer to excluding source control directories in the cloud storage hosting tutorial.

Luckily, the gsutil rsync command has an -x option which allows you to exclude some files/directories from your copy.

gsutil rsync -x "data./.*.txt$" dir gs://my-bucket

Per the documentation (and later I found in gsutil rsync help):

Causes files/objects matching pattern to be excluded, i.e., any matching files/objects will not be copied or deleted. Note that the pattern is a Python regular expression, not a wildcard (so, matching any string ending in "abc" would be specified using ".*abc$" rather than "*abc"). Note also that the exclude path is always relative (similar to Unix rsync or tar exclude options).

https://github.com/GoogleCloudPlatform/gsutil/blob/master/gslib/commands/rsync.py#L438-L446

So to grab all files and exclude .git you just need the following:

gsutil rsync -x ".git" -r . gs://website.com