What does the phrase “to go off half cocked” mean and Where does it come from?

This is what we say in America; the British equivalent is “to go off half cock” or “at half cock.”

Either way the meaning is to speak or do something hastily, without adequate preparation, prematurely.

The original reference, back in the middle of the eighteenth century, was to the musket which, if the hammer was cocked halfway, was supposed to be locked, safe against accidental discharge. But sometimes the mechanism was faulty, the hammer would be released, and the gun would be prematurely discharged, with the musketeer wholly unprepared.

The thought has been expressed that the allusion is to what happens when a hunter, excited upon seeing his quarry, attempts to shoot his gun without releasing the trigger from the safety position while it is still half cocked; hence, that he was unprepared.

But such reasoning seems faulty, for, as nothing would happen, the gun could not be said to “go off.”