To lose weight you have to consume fewer calories than you burn. Vice versa if you want to gain weight.
Simple in theory.
In reality very few of us have any idea how many calories we are routinely consuming.
This is where a short period of food-tracking has some uses. Despite the inevitable inaccuracies the simple act of recording your intake and measuring the results will help you to...
a) Gauge how much you are currently eating
b) Learn the energy cost of your favorite foods
c) See what your ideal intake looks like (food choices, meal frequency, portion sizes)
d) Keep your mind focused on the task at hand.
Once you are finished with your experiment you will also be armed with an internal database of knowledge which allows you to make intuitively better choices going forwards.
No doubt its pretty tedious. But a short-period of tracking can deliver excellent long-term results.