Watch the Lucky in the South: 2 online guitar lesson by Carl Verheyen from S.W.A.T. Sessions: Jazz Rock

Besides my use of the melodic minor a 4th down on the dominant II chord, I also use the Lydian mode on the G major chord in bar 5. This scale contains a #4, which is appropriate because we're in the key of D major and G is not only the IV chord here, but a C natural doesn't sound right when the D major scale has a C# in it. When in doubt, use your ear to tell you this stuff. Theory is only there to explain why what you just did sounds good!