Here's the command: "By company, into line. March!"
Here's the words:
SCHOOL OF THE COMPANY
The company being in march by the flank, to form it by company, or by platoon, into line, and to cause it to face to the right and left in marching.
153. The company being in march by the right flank, the instructor will order the captain to form it into line; the captain will immediately command:
1. By company, into line;
154. At the command march, the covering sergeant will continue to march straight forward; the men will advance the right shoulder, take the double quick step, and move into line, by the shortest route, taking care to undouble the files, and to come on the line one after the other.
155. As the front rank men successively arrive in line with the covering sergeant, they will take from him the step, and then turn their eyes to the front. 156. The men of the rear rank will conform to the movements of their respective file leaders, but without endeavoring to arrive in line at the same time with the latter.
157. At the instant the movement begins, the captain will face to his company in order so follow up the execution; and, as soon as the company is formed, he will command, guide left, place himself two paces before the centre, face to the front, and take the step of the company.
158. At the command guide left, the second sergeant will promptly place himself in the front rank, on the left, to serve as guide, and the covering sergeant who is on the opposite flank will remain there.
159. When the company marches by the left flank, this movement will be executed by the same commands, and according to the same principles; the company being formed, the captain will command guide right, and place himself in front of his company.
What usually happens is the men form a mist or cloud of reenactors, wobble diagonally, and then push and shove each other into the proper line.
If only they looked at the pictures:
Clearly, the secret to doing this simply, easily and without turning the air blue with curses is to UNDOUBLE FILES before moving diagonally. Then your battle line is already formed and the men can trot to where they belong.
No kidding, guys, it really works.