When did military units stop being associated with a particular state?

Sometime after the civil war, military units stopped being called “the 5th Massachusetts” or the “7th Maine” or whatever it was. When did this happen and what’s the story behind the change to non-state specific units?

The short version would be that continental/federal/regular army military units were never associated with a particular state. Militia/National Guards and volunteer units formed by the states continued to be named for their origin until late WWI or thereabouts, when they were brought into harmony with the numbering scheme of the army as a whole.

Some (national guard) regiments have retained portions of their former nomenclature - the former 15th NY national guard regiment remained the “Harlem Hellfighters” even if their official nomenclature became the less descriptive 369th Infantry Regiment.

By that point the basic unit size had moved up several echelons - divisions were the major chesspieces rather than regiments. While there were a number of national guard divisions up through the second world war there were only a couple of states capable of fielding an entire division - the Texas divison, the Keystone division, etc, so most national guard divisions were composites from a number of states.

In addition, the Civil War revealed a weakness in having units being geographically organized: heavy casualties suffered by a particular unit would mean a disproportionate sacrifice by the region that unit came from. During the Civil War there were cases when virtually none of the men who went off to war from a certain county or town ever came back again.

Similar results on a family level during WWII led to the current military policy of not assigning brothers (or sisters, I suppose) on the same ship or in the same unit – having all the brothers in a family killed in the same incident was hard on the family (and bad publicity for the military).