What is the history of the idea of a whole military sharing more or less the same uniform? from my understanding of medieval warfare, and even to the american civil war, it was common for soldiers to just wear what they brought and hope its matched. In perhaps a more easily answered question at what point did militaries begin to issues their own uniforms?
While the real start of this was well into the Middle Ages, the modern usage of military uniforms comes from the Thirty Years War, with Gustavus Aldophus of Sweden creating a very modern army that was more focused on movement, tactics, and training rather than masses of pike squares.
Since the Swedish were having more emphasis on lines of muskets supported by pikes, they had their troops wear rough uniforms provided by the state (since the Swedish army was small enough, it was affordable) that gave them a sense of espirit du corps in the Christian army of Sweden. Musketeers would be wearing only cloth since the pikes would defend them and the pikes could have heavy armor because the muskets would weaken the enemy before it reached the line.
While there are earlier instances that I can't speak very well on, the Swedish army in the Thirty Years War is one of the first examples of a "modern" army fighting with uniforms.