It is easy enough to "analyze" the OP's version as common practice harmony but (like the OP?) I don't find it very convincing musically. It's far too "fussy" - J S Bach could get away harmonizing a simple folk tune with transient key changes on almost every note, but not this composer.
The tune is only "in G major overall" if you want to hear it that way. It works just as well in E aeolian, except I put a G chord on the last note. That way, the problem F# isn't a leading note at all.
BTW if your harmony textbook says the 6/4 chords in this version are "wrong", the check if your ears agree with the book, and if not, find a different book :)