Since these are sample fugue subjects, here is my take:
Because these are all examples of motion from scale-degree 5 up to scale-degree 1 in the key of C, they seem to be showing that, in choosing a lower neighbor to G, you can have either F or F♯. Since using F♯ in no way alters the local tonality, you are welcome to use either option.
One reason why this is important to show is that, since these subjects begin with scale-degree 5, they require tonal answers (not real answers). This lower-neighbor motion from the G will result in the same tonal answer, which (I'm guessing) is one rationale for having the examples presented in this way.
In some other fugal circumstances—like if these were countersubjects or some other extra contrapuntal material—you may want to shy away from using F♯ if you want to make it extra clear you're in tonic and not moving to the dominant.