What does ‘know one’s onions’ mean?

Speaking of knowing his onions … this doesn’t refer to the vegetable.

This phrase was first recorded in a 1922 issue of the magazine Harper’s Bazaar. If you know your onions, it means that you know what you’re talking about, or are knowledgeable about a particular subject.

Nowadays, we tend to simplify this phrase as know one’s stuff, but comparing it to food seems more interesting!