In the ancient Near East, both men and women wore flowing tunics, around which they’d wear a belt or girdle. Although a comfortable garment, they were impracticable, when a man was fighting or performing hard labour, as the hem would get in the way.
So when ancient Hebrew men went into battle, the hem of the tunic would be pulled up, and tucked into the girdle or tied in a knot to keep it off the ground.
The effect basically created a pair of shorts that provided more freedom of movement. Thus to tell someone to “gird up their loins” was to tell them to get ready for hard work or battle. It was the ancient way of saying “man up!”