The song commemorates the Battle of Prestonpans, fought on 21 September during the Jacobite rising of 1745. Forces led by the Stuart exile Charles Edward Stuart defeated a government army under Sir John Cope, whose troops broke in the face of a highland charge. The battle lasted less than fifteen minutes and was a huge boost to Jacobite morale, while a heavily mythologised version of the story entered art and legend. Cope and two others were tried by a court-martial in 1746 and exonerated, the court deciding defeat was due to the «shameful conduct of the private soldiers».
Adam Skirving, a local farmer, visited the battlefield later that afternoon where he was, by his own account, mugged by the victors. He wrote two songs, «Tranent Muir» and the better known «Hey, Johnnie Cope, Are Ye Waking Yet?», using well-known tunes which still feature in Scottish folk music and bagpipe recitals.