Green’s Dictionary of Slang

gum n.2

[God, or abbr. God almighty]

[19C+] a euph. for God (almighty) and used in various phrs., esp. by gum!

In exclamations

by gum! (also by gom! by gummie! by gums! gum! my gum!)

[19C+] a euph. excl. for by God!