Where does the expression “to stick to one’s guns” come from and What does it mean?

The expression “to stick (or stand) to one’s guns” means: To persevere in one’s course despite obstacles; to hold out for, or insist on, a desired course; to maintain one’s position.

Obviously, the origin is military, pertaining to any commander who is determined to maintain a present position in the face of heavy attack by an enemy.

As such, it could have been said of any determined leader since the invention of the gun.

Curiously, however, our figurative usage traces back little more than a century, the earliest being found in Samuel Warren’s popular farcical novel, Ten Thousand a Year (1839), in which the timorous character, Mr. Titmouse, in an argument, “though greatly alarmed,” is said to have “stood to his gun pretty steadily.”