I really, really recommend watching this lecture:
The Human Microbiome: A New Frontier in Health by Susan Lynch
https://www.youtube.com/watch?v=XCaTQzjX2rQ
What food you eat certainly influences conditions in your gut, which influences your gut microbiome. On the other hand, your gut microbiome is highly persistent and even efforts to diet may not have the direct impact you'd think it would. Also, other factors (like conditions at birth) have strong effects that are highly persistent.
If you're not familiar with this research you really owe it to yourself to learn about it.