Here is what I learned from the garlic wiki:
"Abundant sulfur compounds in garlic are also responsible for turning garlic green or blue during pickling and cooking. Under these conditions (i.e. acidity, heat) the sulfur-containing compound alliinase react with common amino acids to make pyrroles, clusters of carbon-nitrogen rings.[74][75] These rings can be linked together into polypyrrole molecules. Ring structures absorb particular wavelengths of light and thus appear colored. The two-pyrrole molecule looks red, the three-pyrrole molecule looks blue and the four-pyrrole molecule looks green (like chlorophyll, a tetrapyrrole). Like chlorophyll, the pyrrole pigments are safe to eat.[76]"