I read a book about this once, forget the title. Greenland’s cores have clear annual layers for several thousands of years (validated by extra ash layers from known volcanic eruptions), and they can measure carbon and temperature from the isotopes trapped inside (temp is measured due to some effect of oxygen isotopes following a reliable temperature gradient or something like that, they had a couple independent measurement methods that matched up). At some point the compacted layers start to merge but they can still reliably estimate because the overall cyclic trends (on multi thousand year scales, due to mathematically regular wobbling of earth’s rotation and other factors) follow the same trends from the clearly annual layers. This goes back several hundred thousand years, with temp increases always following carbon increases.
Edit: the book was The White Planet by Jean Jouzel, Claude Lorius, and Dominique Raynard