from Old English gang "a going, journey, way, passage," and Old Norse gangr "a group of men, a set," both from Proto-Germanic *gangaz (cf. Old Saxon, Old Frisian, Danish, Dutch, Old High German, German gang, Old Norse gangr, Gothic gagg "act of going"), from PIE root *ghengh- "to step" (cf. Sanskrit jangha "shank," Avestan zanga- "ankle," Lithuanian zengiu "I stride"). Thus not considered to be related to go.
The sense evolution is probably via meaning "a set of articles that usually are taken together in going" (mid-14c.), especially a set of tools used on the same job. By 1620s this had been extended in nautical speech to mean "a company of workmen," and by 1630s the word was being used, with disapproving overtones, for "any band of persons traveling together." Gangway preserves the original sense of the word, as does gangplank.
1856, from gang (n.). Related: Ganged; ganging. To gang up (on) is first attested 1919.