Old English crammian "press something into something else," from Proto-Germanic *kramm- (source also of Old High German krimman "to press, pinch," Old Norse kremja "to squeeze, pinch"), from extended form of PIE root *ger- "to gather."
From early 14c. as "fill with more than can be conveniently contained." Meaning "study intensely for an exam in a short time" (with a view to passing the test, not real learning) is attested by 1803, transitive as well as reflexive, originally British student slang. Related: Crammed; cramming; crammer.