What I do is shift my focus. If you think about
what you can't have, You will crave that. The human brain can't think in a void. For example, if I said
"Don't think of the color blue" you know you thought of it, you can't not.
So think of that with your diet. Think of what you can have and how it will help you
Eat veggies and think of how they are helping you. When you are hungry ask yourself what will nourish you.
Also plan ahead. If you can make larger portions then parse them out of later it makes food easier. I make my smoothies the night before.
But most important is to look at your diet not as what you can't eat, but how what you can eat will help you.
I also created some associations in my mind to bad foods, I see dairy and I see mucous, gluten makes me think of physcal muscle pain, sugar makes me think of bacteria growing.
Greens make me see vibrance and health, sweet potatoes look like energy to me.
Reframe your mindset about your diet and you will start to find that going with the flow is just easier. You'll slip up, be gentle on yourself, and then pick up and crave some cucumber.