I don't have any solid advice, since this is exactly what I've been struggling with for years. If you mean cravings where you can't think about anything else until you eat X food, then I'm right there with ya.
Unlike the other people who posted, 9/10 times I cannot eat the food I crave or else I'll spiral out of control. Most often my overbearing cravings aren't for a serving of X or Y, it's for a whole bag/box of it. One serving won't do, and trying to only do that leads to a worse overeating episode than if I'd just resisted. For me, moderation doesn't work most times.
For me, I always feel like I might actually die if I don't eat X food, or my body starts getting achy if I resist too long, I can't think about anything else, and it literally feels like the sensation will never end if I don't give in. I don't know what causes these cravings, but it can be really brutal.
One good things is that, for me, the cravings for specific foods change over time. I used to not be able to have peanut butter in the house without eating the whole jar. Now I have no problem with it.
I have not found a solution other than to give in to the cravings and steadily gain weight. That is not an option for me, and I assume it isn't for you either. But there are a few things that have helped me in the past, and some that I'm trying now.
Things I've noticed have helped are:
1. Don't let yourself get too hungry. It ramps up the urgency of the craving, which is very bad.
2. Distract yourself. Do something you get absorbed in. It doesn't need to be super fun, just something that uses up your attention so you don't think about food. For me, it has to distract me mentally or it doesn't work.
3. Run away. If I start feeling the cravings growing, I will flee the room/house/etc. to save myself.
4. Whatever you crave, don't bring it in the house. This may not work if you don't live alone (I don't, so this is always a fail).
5. White-knuckle through it. Sometime, anyway. There will be some cravings that you just can't shake until they go away, and nothing is enough of a distraction. Just hang on, keep reminding yourself why you don't give in, and believe that the cravings WILL go away eventually. This won't work for every time, since it's very draining on your willpower and energy. But once in a while it's what's needed.
Often it is just time that's needed for some cravings to go away. However, it can be a lot of time, and it may come in waves. I've gone several days with nearly constant, almost overwhelming cravings. It's very tiring, and at the end of the several days it's like I've been hit by a bus. It's very hard to resist that long. And it doesn't even feel that rewarding when I do, honestly. But it's what needs to be done.
Anway, that's a very long answer for what is probably a simple problem. For me, cravings are rough and complex. If it's the same for you, I hope any of those tips help at all. If it's not the same for you, I'm very glad (they're not fun).
Good luck with your weight loss!