There are lots of old school photos on the internet.
Thinking back to Primary School, which would have been the early 1960's in the UK for me, there was very little difference in length between boys and girls hair. This was in the dying days of Brylcreme and the boys often had their hair slicked down (or with spit!) whereas the girls might run to a plain hair grip if their fringes were growing out.
I can only remember a couple of girls in Primary School whose hair was shoulder length or longer. One was very "dolled up" with her hair in bunches with ribbons and the other other was very unkempt. Nobody wanted to share a desk with her because the poor girl stank to high heaven. One was a "little princess" and the other was poorly clad and sadly neglected. Long hair was a sign of the extremes of parenting rather than the norm.
I dug out a group photo from my primary school which confirms my memory. Other school photos on the internet show much the same pattern: boys with short hair, most girls with the same length or very slightly longer hair and one or two girls with hair shoulder length or longer.
Photos on the internet show a change for primary school children in the 70's, with few boys having hair as short as in the 50's and 60's and more girls having longer hair.
One of the reasons for long hair persisting as a fashion must be the availability of hair conditioner. Another would be the availability of kinder, more attractive, ways to tie up your hair than rubber bands and knotted "knicker elastic". Before hair conditioner there was only shampoo or soap and, if you were lucky, having your hair smothered in raw egg or rinsed in lemon juice, vinegar or beer as "conditioner".
Short hair was much less painful than the torture of tangles being combed out and then having your hair dragged tight through a rubber band and pulled out by the roots when you let your hair down. If young girls had long hair it was not usually their choice.
You can also tell from looking at photos from the 50's and 60's that most primary school age children had their hair cut at home. The boys don't look quite as bad as the girls and my brother, who is two years younger than me, was taken to have his hair cut at the barber long before I was treated to a trip to the hair dresser. By the look of those old photos on the internet, I would guess that that was the usual way of things.
Two friends in Junior School had hair in long plaits down to their waists because their mothers would not let them cut their hair. As soon they felt able to defy their mothers, in their late teens, they had their hair cut in a bob. There were more girls with shoulder length hair in Secondary School but not many had their hair any longer than that.
Going back to Primary School, in the 50's and 60's school clothes were very gendered even if there was no uniform, so it was not difficult to tell girls from boys. Hair length was not the distinguishing feature. Out of school, it was not uncommon for girls to wear trousers out playing. I do not recall anyone ever mistaking a girl with short hair and wearing trousers for a boy.
In most cases there might have been subtle or more obvious clues in the clothing that gave the game away: girl's blouses often had obviously or slightly different collars to boy's shirts ("Peter Pan" style collars were rare for boys by then); buttons on girls' clothes might be "fancy" where boys' would be plain; etc.
Something that struck me looking at school photos from that time, when children are not in uniform, is that the girls are often wearing lighter-coloured clothes than the boys. The photos are black and white but it is obvious that more girls are wearing pastel or pale colours and more boys are wearing dark colours. It is impossible to tell how many are wearing bright, deep colours.
The only time I was mistaken for a boy was when I was about ten or eleven, had a "boy haircut" (an "Eton Crop") and was wearing shorts on holiday in Spain. Spanish girls were dressed much more traditionally at that time and long hair was the absolutely the norm so the mistake was understandable.
I remember reading KatieAlcock's fascinating article mentioned earlier:
medium.com/@katieja/young-children-reality-sex-and-gender-3421f4f165f1
Those children are younger, pre-school, but if older children are now having difficulty distinguishing girls from boys, based on expectations about hair length as a signifier, why is that?
Has hair length become so much more salient that it over-rides other clues? Does a Primary School age girl with short hair need to go all-out for uber-Pink with girly logos and images on clothing to be perceived as a girl - or would even that not be enough?
Is the confusion the result of it being drummed into them at school, in children's TV, etc. that the girl-boy distinction is not stable, that the sexes can flip so they either cannot trust their first impressions or are unable to form a clear first impression, thrown off course by hair length?
Androgyny seems to have been lost as a sexed option and does not seem to be on their RADAR yet as a "non-binary" interpretation. So is there is a complete pendulum swing between gender stereotypes, with hair-length being the clincher?
In the days when it was normal for young boys to have long hair and wear dresses (mid to late 19th century?) their clothing was still styled slightly differently to girls'. If colour was used to signify sex it was pink for boys and pale blue for girls so there were still some clues. Not hair though.
It is all cultural of course - but was there ever a time when school-age children in the UK, as mentioned in some of the posts here, had problems determining the sex of other children the same age? Not a rhetorical question - and I am not sure how we would know, unless it cropped up in literature maybe?