Where did all the gases in the earth's atmosphere come from?

Scientist theorize that bacteria with chlorophyll in them slowly but surely began to multiply. And as they did, they photosynthesized enough to create an entire atmosphere. (as you know oxygen is a byproduct of photosynthesis)