As your doctor
probably told you, gastritis is a condition in which the stomach produces excess acid, and this can lead to symptoms like heart burn or pain in the stomach when eating.
The treatment of gastritis does involve dietary modifications. In particular, it is important to avoid foods that might make the acid production worse or cause more acid to reflux into the esophagus. There is a long list of foods that can do this, including common offenders like alcohol, coffee, tomatoes, and chocolate. For some people, fatty foods can also be a problem, but this is a bit more variable from person to person.
In addition to following the dietary advice that your doctor gave you, you should also take any medications that they recommended, such as anti acid medications, while avoiding stomach irritating medications like ibuprofen or aspirin. You should also think about stopping smoking, if you have that habit, as smoking is very irritating to the stomach and can make gastritis work.
After working on these things, including the diet, for a while, you should see your primary care doctor
again to see how things are going. They can help you evaluate whether or not your symptoms are improving and, if not, suggest additional treatments.