I previously worked for a major tank truck company. The company had a large fleet of tankers in several metro markets. I can guarantee you that there is a LOT of different gas that comes to different stations, especially in a metro area. Our trucks would pick up from about 5 different pipeline terminals in one metro area and deliver to various branded stations. It is entirely possible that the branded station you buy from does not have a pipeline terminal in your market! Their stations get there gas from whatever pipleline serves the market.
Even when you go to a branded pipeline terminal to fill a truck, you have ZERO idea of where the gasoline really came from on the other end....it has moved hundreds of miles from "some" refinery or storage yard....no way of knowing whose. Some branded purchasers will specify certain additives to be put in by the tank truck driver....and some won't!
Simply put, your best bet is to buy from a station that does a high volume and "turns" the gas frequently. Just because you buy from a Shell or Mobil or BP station there is absolutely NO guarantee of any sort that the gasoline from that station was refined by the branded company. Actually, there is a very, very high chance it was not!
The EPA and state authorities specify what gas blends can be sold in specific areas. This is by far, the biggest determinant of what gasoline you get. There are lot of blends around the country. If the Shell station in your area is required to use Blend "X" and Shell doesn't have it available, they will simply buy it from another source and truck it to their branded stations. Your local "BP" gasoline may very likely be refined by Valero petroleum or another independent refiner!....or Shell....or Chevron!!...
The other major factor in whose gasoline goes to what station is simply distance. The Branded Companies usually by from a CLOSE pipeline terminal, regardless of whose. They are not dumb...they don't want to pay higher freight charges to the tank truck company. Distance is money. They are not about to truck 6,000 gallons of gasoline for 50 miles when there is a "competitive" terminal 4 miles from the station. This is just economic sense and again why is very likely the brand of gas is NOT what the big sign on the station says it is !!
Bottomline: There is virtually no way for the retail consumer to know where the gasoline they purchase at a retail station is refined or WHO refined it.