I've gotten in shape a few times, and the way I've done it each time is to follow a simple strategy:
1. Find a workout program or a youtube channel that has workouts I like to do.
2. Eat as healthfully as I can most of the time.
3. Drink water.
4. Work on my mindset issues.
That strategy works for me every time; the only reason I deviate from it is because when I reach a goal I get bored, or I don't have another goal to work on. I'm determined this time to keep myself in good shape once I get back to my goal.