How to avoid garlic turning blue after cooking?

At times I notice that chopped garlic turned to a striking blue or green colour after cooking. They taste alright, but it’s ghastly to look at. How to avoid that? Thanks all.

Never had that happen to me. Is it a particular type of garlic, or the normal stuff?

Normal stuff. Happens often for example, when putting them inside a fish to cook in an oven.

It happens. For me, when it is sitting in butter for extended periods - though not every time and typically just rarely. I don’t think there is anything you can do to stop it.

I’ve seen this question before - someone will chime in with the chemistry behind it but I can’t remember the specifics of why it happens right now.

Edit: quick search turned this up - fairly reliable source

Thanks for the link, I think I read before like it’s in touch with acid. But it’s not always happening.

Actually just wants it not to happen!