How do I know what is giving my baby gas?

Make a diary. Creating a daily diary of foods, bowel movements, and gas can be helpful in finding the culprit.
The usual suspects. There are some well known culprits that can cause gas with breastfeeding: cabbage (and that includes coleslaw, sauerkraut, and egg rolls), caffeine, spicy foods, onions and garlic, broccoli, carrots, asparagus, and large amounts of dairy or tomatoes. Some can have one thing and not the other, or even another food. If you find there is a "timing" to the gas, start a diary, or eliminate offenders.