If a piece of music uses notes from the G major scale, it is said to be in the key of G major. Because the G major scale contains the note F#, this note is often used in the key of G major.
Instead of writing a sharp sign before every F note, it is easier to write just one F# after the treble clef to indicate that all F notes are to be played as F#. This is the key signature of G major. It can be seen in the following example.
This beautiful melody was written by classical composer Johannes Brahms. It is written here in the key of G major, as indicated by the key signature, which reminds you to play all F notes as F#. Play slowly with a clear, even tone.