Watch the Over Minor Chords online guitar lesson by Rob Garland from The Guitarist's Pentathlon
The lick sounds melodic against the chord because the scale contains the same notes as the chord. A Gm7 chord contains the notes G-Bb-D-F, the Gm pentatonic scale contains the notes G-Bb-C-D-F so it's hard to hit a bad note! The lick I repeated in three different positions through three pentatonic shapes, but you should experiment playing variations of your own licks. Try to create the sound of two dueling guitars by jumping between the low and high registers in the different pentatonic shapes. You can even wear a hat but it's not necessary.