In Old English, the letter g represented four sounds. (Check out the etymological note in the OED for details.) I shall limit my remarks to the two sounds of g in modern English.
Unlike the letter c, which is an alternate spelling for the sounds of k and s and has no sound of its own, the letter g does have one sound of its own: the “hard” sound heard in glove.
The second sound of g, the “soft” sound heard in giant, represents the sound that belongs to the letter j [j].
ESL learners often ask if there’s a rule for knowing when the g represents the “hard” sound and when the “soft” sound. There are guidelines that help, but not all words conform to the guidelines.
NOTE: In mastering English spelling, the sensible approach is to learn the general rules and then, using them as a point of reference, learn the exceptions.
If the g is followed by e, i, or y, the pronunciation is “soft g”:
g+i: magic, margin, origin, engine
g+e: page, generation, detergent, vengeance
g+y: astrology Egyptian gym
If the g is followed by any other letter (than e, i, y), the pronunciation is “hard g”:
If the g comes at the end of a word, the pronunciation is “hard g”:
Sometimes a u follows a g in order to keep it from bumping up against an i or an e:
Exceptions to the e, i, y Rule
Hebrew names: Gideon, Gilead
Words of Germanic origin: give, gift, get, gild, Gilbert, Gilda
Scottish names: Gilchrist, Gillespie, Gilroy
Most English words that derive from the Greek word for woman [gyne] follow the rule for g followed by y and are pronounced with a “soft g,” for example,
misogynist: one who hates or is ill-disposed to women
polygyny: a form of polygamy, marriage of a man to more than one woman at a time
androgynous – having both male and female characteristics
When the word gynaecology to describe the department of medical science that treats of the functions and diseases of women was coined in the19th century, it was pronounced with a “soft g.” Some speakers still pronounce it that way, although the hard g has become the most common pronunciation in both British and American English. (The American spelling is gynecology)
Related post: Womanly Words–Gyn