The reasons for green stools are many. It could be because of what you ate, use of antibiotics and other medications, infections, diseases and history of medical procedure.
If you consume a lot of vegetables or food with coloring your stool is likely to be green, this is simply because the food has not be properly processed.
Bile is a yellow green pigment made by the liver to aid in the digestion of fat. It is reabsorbed in the intestines. If it is not reabsorbed your stool can be green.
If you are taking a medication that increase bile excretion or one that kills normal bacteria of the gut, your stool can become green. Bacteria, viral and parasite infection can cause diarrhea, food is not properly processed, it can also decrease the rate of reabsorption and processing of bile making your stool green in color.