A gallon is equivalent to 128 ounces, or 3.78 liters.
A quart is 16 ounces and a pint is 32 ounces. The value of 128 was derived by combining these two values, 4 quarts equals just over half a gallon (1/2gal = 64oz).
People then started counting out pints to measure liquids in other containers like buckets or barrels and then eventually rulers were made with markings for the measurements they would be most likely to use – one inch equalled 2 feet so that wineskins could have an accurate measurement when gauging the height of wine barrels, but also so that wine merchants could know how tall their wares were as compared to other buildings on the street.