Is your gastritis chronic? In general, you need to eat a lot of food to gain weight, including fats and sugars.
My mum's severely painful gastritis and GERD went away when I took her off nexium (acid blocker) and onto betaine HCL and digestive enzyme supplements. Gastritis is a cause of low stomach acid (and low acid is the most common reason for acid reflux) and proteases (enzymes that digest protein) heals the stomach.
I have gerd and losing weight is normally the best thing for it as well as monitoring what you eat and when. Do not eat at night, for example. Do not lay down with a full stomach, for example. So, you do have to take that into consideration. Acidic foods are difficult on gerd and gastritis like spaghetti or tomato sauce, stay away from cola and coffee. I took medication for gerd which controlled it but when I lot weight, it actually improved so that I don't take medication anymore on a regular basis. Talk to your doctor if you think this is going on, they can help you. https://www.webmd.com/heartburn-gerd/guide/reflux-disease-gerd-1. They can help you direct your diet as well.
If you are losing weight because of digestive disorders, that happens. I also had an ulcer and lost 30 pounds before it was diagnosed. Because I had burning after eating, eating was less appealing and I lost significant weight in a short period of time. It was a duodenal ulcer (in intestines) and took some time to diagnose. Endoscopy found it when other GI tests didn't. But I did indeed have to gain weight after that experience. Once treated, things went back to normal.
Gastritis is different. That's inflammation of the lining of your stomach. Have they determined you have this and if so, the cause? Sometimes it is due to H Pylori and medication clears that up. Acid reducers or proton pump inhibitors are often prescribed. And doctors do recommend to stay away from spicy foods, see WebMD. ANY foods that irritate it should be eliminated. https://www.webmd.com/digestive-disorders/digestive-diseases-gastritis#2
We can't tell you that you don't need to gain weight. Is this a doctor's recommendation? There are healthy ways to gain weight. We can help you with that if you would like. One of the best things you can start doing is to keep a food diary and start tracking things. Add things in that have nutritional value. This article has lots of suggestions https://www.webmd.com/diet/features/how-to-gain-weight#1. There are foods higher in fat content and have more calories but are really good for you. Some nuts or fish like salmon for example. Read through that article and see what you think. It also is never a bad idea to find a nutritionist in your area to speak with and evaluate your situation to make recommendations. Your doctor can likely help you find one. We're here to help if we can!
You don't say what you weigh and why you "need" to gain a lot of weight. Not eating doesn't help either gastritis, which isn't actually a thing, it's just a description of inflammation in your digestive tract but not why it's there, or GERD, which is another digestive disorder that is worse if you have an empty stomach. So if you stopped eating enough because of these two things, it won't help, and might make it feel worse. Most people who have been diagnosed with these conditions don't necessarily have them, or at least not in the sense they think. Doctors diagnose these based on symptoms and generally treat them with acid suppressants, which over time can force the digestive system to compensate by making more and more acid because it must have it in order to digest protein and break down minerals. There are also a lot of different reasons people get this stuff -- bad eating habits, eating disorders, medication, infections -- it's very hard to find the cause oftentimes. There are some treatments some have found effective, such as not lying down or going to sleep soon after eating, which can cause digestive juices to flow upward instead of work in the digestive tract. Avoid foods that bother you, but if they don't bother you, and are healthy, don't avoid them because someone told you to, such as spicy food -- that's often more a cultural thing than a causal thing, as most spicy foods are actually good for the digestive system. But if you're not used to them, they can bother you. As for what to eat, a balanced healthy diet the same as anyone else, with meat in moderation, fish is good as is fish oil, and whole grains and veggies. It's not different really except to avoid things others might not be bothered by even though they shouldn't eat them, such as too much sugar or processed foods or the wrong kind of fat -- the usual suspects. There are also natural remedies that might give you relief over time -- aloe vera juice, DGL, and slippery elm might help without suppressing acid. Tell us what you eat now, if you exercise, if you know the cause of your digestive problems, etc. and you might get better help.