Conny Miller's hat is called a "Campaign Hat" which can be traced back to the mid-19th century. Although made by many manufacturers, Stetson was a major producer of these hats. Soldiers found the middle crease of their hats to be impractical since it accumulated rain water and they started pushing up the center so it would shed water. Sometime in 1911, the Army adopted this style of hat as "1911 Hat, Service, M1911 (Campaign Hat)". Unofficially it had several names: "lemon squeezer", "mountie hat", "ranger hat", "drill instructor cover", "smokey bear", "the Montana crease", and several others.
Many reviewers have cited Leo Rosten's very short story "The Path Through the Cemetery" as the source of this episode. While this much-anthologized tale is probably the immediate source, there are many other available ones which include the three essential story elements: grave, wager, & knife. The oldest printed version in English to be found dates from 1825 when it appeared in the pages of The Terrific Register. The story has been recently reprinted in the compilation Tales From The Terrific Register: Book of Ghosts (2010) pp. 107-112. The setting is Westminster Abbey around the year 1735 when the Henry VII Chapel Vault has been opened for the admission of the Queen's body. (The Queen must be George II's consort Caroline of Ansbach who died on 20 November 1737 and is the only Queen buried in the vault anywhere near the year 1735). The only significant change is that the wielder of the knife survives his ordeal and relates much of the tale in the first person. It should be noted that The Terrific Register was notorious for publishing fiction as fact and that it was probably a well-known legend by 1825.
This episode is based upon a popular urban legend.
Lee Marvin, Strother Martin and Lee Van Cleef all appeared in The Man Who Shot Liberty Valance (1962), which was released six months after this episode was broadcast.
In the bar of this late 1800's setting, you can see a stuffed "Jackalope" mounted conspicuously above the back of the bar. This is a possible inside joke among the set crew; and highly incongruent in that setting, since the myth of the Western "Jackalope" (an alleged and impossible hybrid between a jackrabbit and antelope) was an urban tale concocted for the tourists visiting the west in the 20th Century. It was an especially popular joke in post-war mid century America.