Stool can become green for several reasons. A yellow-green liquid called bile is added to food in the small intestine to emulsify fats, making them easier to digest. Normally, bacteria gradually change a yellow pigment in the bile into a brown pigment as the food travels through the intestines, given the stool its typical color. However, if the food is transported through the intestines faster than normal there may not be enough time to form the brown pigment, and the stool appears green. This may happen in irritable bowel syndrome, after ingesting certain irritant foods or due to certain parasite infections.
In addition, eating lots of green plants, purple foods and drinks or iron supplements can cause green stool.
This article contains more information.