Old English dic "trench, ditch; an earthwork with a trench; moat, channel for water made by digging," from Proto-Germanic *dikaz (source also of Old Norse diki "ditch, fishpond," Old Frisian dik "dike, mound, dam," Middle Dutch dijc "mound, dam, pool," Dutch dijk "dam," German Deich "embankment"), from PIE root *dheigw- "to pierce; to fix, fasten." The sense evolution would be "to stick (a spade, etc.) in" the ground, thus, "to dig," thus "a hole or other product of digging."
This is the northern variant of the word that in the south of England yielded ditch (n.). At first "an excavation," later applied to the ridge or bank of earth thrown up in excavating a ditch or canal (late 15c.), a sense development paralleled by the cognate words in many languages, though naturally it occurred earlier in Dutch and Frisian. From 1630s specifically as "ridge or bank of earth to prevent lowlands from being flooded." In geology, "vertical fissure in rocks filled with later material which made its way in while molten" (1835).