I will also note that Confederates had Hardee, who wrote the drill manual used by both sides.
Confederates tended to wait a little longer to install their bayonet. That gave them a bit higher rate of fire at some key portions of a close fight, that might have helped a lot. Without antibiotics, cutting your finger on the bayonet could lead to an infection, so with bayonet installed your loading was slowed significantly.
Upton is thought to have considered that when he developed the fast moving assault tactics used in the Mule Shoe during the overland campaign. His idea was to move quickly through the enemy fire, and at very close quarters, the remaining US soldiers would have their bayonets fixed, and the Confederates would be reaching for theirs.
Per Wikipedia re: Spottsylvania Court House
“Grant used Upton’s assault technique on a much larger scale on May 12 when he ordered the 15,000 men of Maj. Gen. Winfield S. Hancock’s corps to assault the Mule Shoe. Hancock was initially successful, but the Confederate leadership rallied and repulsed his incursion. Attacks by Maj. Gen. Horatio G. Wright on the western edge of the Mule Shoe, which became known as the “Bloody Angle”, involved almost 24 hours of desperate hand-to-hand fighting, some of the most intense of the Civil War.”
Yes we’ll rally round the flag, boys, we’ll rally once again,
Shouting the battle cry of freedom,
We will rally from the hillside, we’ll gather from the plain,
Shouting the battle cry of freedom!
(Chorus)
The Union forever! Hurrah, boys, hurrah!
Down with the traitors, up with the stars;
While we rally round the flag, boys, rally once again,
Shouting the battle cry of freedom!
(Chorus)