When did the US Army start requiring soldiers to shave?

Inspired by Chefguy’s thread about stolen valor. Back in the days of the Civil War, it seems like beards were almost a requirement, with Grant, Sherman, etc. all sporting full beards. By the time of WWII it seems like being clean shaven was the requirement. What happened in between these time periods and when that led to this change? Google is not of much help, as all the links I found are about modern requirements and talk about things like exceptions for Sikhs or people with certain skin conditions.

This article about facial hair standards in the British army suggests that having it was a distinct disadvantage in WWI, and could get in the way of your gas mask use

Was facial hair well-accepted in the rank and file of the Civil War? I seem to recall in the French Napoleonic-era armies, individual units might have a mustache or beard as a signature look but the rest were typically clean-shaven, but I do not know if this was due to tradition or a firm regulation. Similarly, I can’t recall any pictures of an American Civil War line soldier with a beard, and I don’t remember whether I’ve seen one with a mustache one way or another.

Possibly commanders having a beard was allowed because they were exempt from the normal regulations?

If this post on Etsy is to be believed,it started in World War I.

I imagine the introduction of the safety razor in the 1880s made it a lot more practical for soldiers to shave in the field.

Here’s a collectionof civil war photos. Several show enlisted men on both sides with beards or moustaches.

This web page agrees:

My bold. Even today mustaches are allowed in the US Army within regulations. We should be careful to draw a line between mandatory shaving of the beard (along with some of those stupendnous Civil War sideburns) and being clean shaven.

But mustaches were not allowed for all the years between the Civil War and today. As others noted, they were forbidden starting in WWI. They didn’t get allowed again until the sometime in the 1970s, IIRC. And even then, they could only be rather modest, i.e. not extending past the edges of the mouth.