When you see pictures or recordings of urban warfare during ww2 and afterwards, it’s usually of soldiers using bombed out buildings as cover and fighting street to street. But this was done using the aid of a variety of modern equipment and weapons such as bombers, tanks, and more. So how was this type of fighting done before then, when soldiers were still being issued muskets and stood in formation?
Some armies did consider tactics and movements when fighting in urban settings in the 18th century. The British Marines, American leaders, and others wrote manuals of exercise that included some aspects of fighting in what call urban settings. While most military leaders would vastly prefer fields and such to fight on, urban encounters did happen with bridges, streets, and houses used as the terrain. Contrary to most belief, leaders did have flexibility with placement of men and knew lining up men in the open streets would not lead to a successful battle.
A few happened in the American War for Independence, such as Siege of Quebec in 1775 and battle of Germantown in Pennsylvania in 1777. I believe a few happened in earlier wars such as War of Spanish Succession and Austrian Succession but I am not as familiar with those. Battle of Blenheim seems to be an example of one instance urban fighting occurred. Towns offer cover and a strongpoint to hold while attackers have to use artillery to push defenders out.
These armies of course do not have the same arsenal as later armies of the twentieth century do, but they still had some semblance of tactics in cities or towns. Military leaders filled those voids with muskets and artillery. The British used platoon or some other sub-divisional fire in their warfare on battlefields, and they employed the same tactic in the streets. Different subdivisions and wings would cover each other and fire at different times so that the rate of fire did not slack. A manual notes that "not an inch of ground" could be lost while doing these maneuvers. As a division or sub-division fired they were to fall back to a safe position to reload, while another division rushed up to that position to fire their rounds. It would rotate to the other seven divisions as they covered each other and gave time for reloads. This revolving fire would offer the rate of fire that armies needed in battle, especially in a street.
Early in the American war, Thomas Pickering published a manual of exercise and included a portion of street firing as well. It is similar with firing by subdivision or company, and to rotate companies that have fired to the back under the cover of other subdivisions for them to reload. Lewis Nicola would publish in his manual of exercise in Philadelphia with the street firing in 1776 before the Pennsylvania campaign began. Without presuming their thoughts, they seemed to want to prepare for the cases that fighting in towns or civilian structures occurred. For the lack of tanks, bombers, and more mobile artillery, firing by subdivision/company would be the strategy implemented by both the British and Americans.
The Battle of Quebec in 1775 turned to heavy urban fighting during the American assault. The Americans did bring artillery by the means of John Lamb and used them, but the British had fortified the city knowing they would be a target after Montreal fell with some palisades, blockhouses, and other small fortifications. The battle made its way into the city, and the British fired from house windows. The battle was one of the rare instances of melee combat as some Americans and British fought against each other with bayonets in close quarter combat. I do want to point that the American artillery did destroy and damage many civilian homes, but did not do enough to push out British forces. The fact that the battle occurred in late December during a blizzard did not help the case either.
Sources:
Terence O' Loghlen, The Marine Volunteer Containing the Exercises, Firings, and Evolutions of a Battalion of Infantry, 1776.
Thomas Pickering, An Easy Plan of Discipline for a Militia, 1775.
Lewis Nicola, A Treatise of Military Exercise, Calculated for the use of Americans, 1776.
This is a cool question because it ties in almost directly with modern-day considerations that militaries are currently grappling with (particularly the United States). With the rise of large cities, metropolises, and megacities (cities with more than 10 million inhabitants) and the potential for conflicts between nations with professional militaries or large cities becoming a looming concern (versus conflicts where the US largely faces guerrilla or insurgent forces). The US military is attempting to establish a doctrine that can respond to this BUT I digress before I get even more longwinded and break the 20-year modern history rule.
Similar to today, this answer places the United States military in a time of transition. Some of the wars in the 19th and 20th centuries saw the military struggling to adapt to a rapidly modernizing society (and thus a changing battlespace) while also working to fight against more mobile groups of Native Americans across the growing American West or the insurgency during the Philippine Insurgency (ie not totally urbanized and more insurgent based). Think about the difference in warfare between fighting against an insurgency versus massive battles like Gettysburg. How does one establish an effective doctrine? Or the difference between Korea and Vietnam.
While I cannot attest to urban/guerrilla warfare across global history, I can answer with some anecdotes from American history before World War Two (which itself proved to be a testing ground paid for in blood for establishing concrete military doctrines for operations within urban environments). An important thing to note here is that humans were not always concentrated in established urban settings and this growth in city size continues to grow exponentially into the 21st century. These changes, coupled with developments in technology, changed how wars were fought. Additionally, one should note how society viewed warfare (European military doctrine influence on the US military), manhood, and honor.
A good example here is the 1846 Battle of Monterey. In the Mexican-American War, sections of the US forces under the command of General Zachary Taylor (future president) were tasked with taking the town of Monterey, a heavily fortified town south of the Rio Grande. American troops found themselves assaulting both urban and fortified positions, much different than previous battles of the Mexican-American War. Here, as in the future, plans were paid for in blood. Historian Johnathan A. Bell writes, " West Point cadets learned a great deal about military engineering and fortifications, something on siege warfare, but nothing on fighting in cities." This would force the attacking American and Texan forces to adapt quickly to urban combat (and abandoning open field tactics more common for the time period). After learning the dangers of rushing down alleyways and streets without suppressing fire, American's quickly took towards busting down doors and rapidly clearing rooms with their sidearms, not very different from how future Americans would clear rooms in future wars. This was very much out of necessity rather than doctrine, though. This room to room and house to house clearing combined with effective use of moving under suppressing artillery played a pivotal role in ensuring American advancement into the city.
Contrast this battle, however, to the Battle of Vicksburg in 1863 during the Civil War, however, and one can see how siege tactics still played a role in American military doctrine. Of course, this course of action may have made sense given the resources and technology at the time, but it also differs from how urban warfare has changed over time. Now mass sieges or indiscriminate bombardments of civilian populations are against international law, thus forcing more precise use of munitions and troops. The tl;dr version would be that lessons were often learned from losses and these losses impacted how on the ground leaders or commanders led or directed their men. It would be several generations until there was an effective and widely thought doctrine that focused on urban warfare (for the US, at least).
Sources:
Hoffmann, Alvina. "The Urbanization of Warfare: Historical Development and Contemporary Challenges for International Humanitarian Law." St Antony's International Review 12, no. 2 (2017): 176-89. Accessed December 1, 2020. doi:10.2307/26229179.
Beall, Jonathan A. "The United States Army and Urban Combat in the Nineteenth Century." War in History 16, no. 2 (2009): 157-88. Accessed December 1, 2020. http://www.jstor.org/stable/26070721.
Joes, Anthony James. Urban Guerrilla Warfare. Lexington, Kentucky: University Press of Kentucky, 2007. Accessed December 1, 2020. doi:10.2307/j.ctt2jckq0.
and the Modern War Institute of West Point, Urban Warfare Project https://mwi.usma.edu/urban-warfare-project/