(Note: the premise of the question was incorrect, but in the spirit of clarity and aid for future readers, I want to answer the actual stated question. There's nothing worse than finding your exact question online and then not finding an answer, so hopefully this will prevent that.)
Any time you see a major chord in an unexpected place—like a D-major chord in F major, where you would normally expect a D-minor chord—see if you can understand it as a temporary dominant of something else.
In other words, D major is the dominant (V) of G minor. So more often than not, a chord like D major in an F-major environment is functioning as a V of that G minor. We label it a "V/ii" (spoken "five of two"), because ii in F major is G minor, and D major is the dominant of that ii chord.
If this D-major chord comes immediately before (or even after) a G-minor chord, then it's functioning as a V/ii.
In more rare instances, this D-major chord might not do that; it might go, for instance, to a IV chord. This is relatively uncommon, but it's typically not functioning as V/ii in these instances, but rather as a modified VI chord. Some would also call this a "chromatic mediant" of the tonic.