English is a mix of languages, essentially of Germanic origin (mainly Anglo-Saxon) and of Latin origin (mainly French). Germanic is the core of the language, the grammar is derived from it, as is the "basic" vocabulary. French and in some cases Latin directly were added later on, and most of the "extended" vocabulary derives from it, or in some cases, from Greek.
The pronunciation of the "G" is therefore largely dictated by the etymology of the word. You'll see that in the most common words: girl, get, together, gift, etc. the "G" is always hard. However, for words borrowed from French, Latin and Greek (often technical, scientific, legal, etc), the "G" follows the French pronunciation: in front of the vowels "e", "i", and "y" it is soft, otherwise it is hard:
giant (French "géant")
gentle (French "gentil")
gymnasium (Latin)
engine (French "engin")
vagina (Latin)
gyroscope (French from Greek words)
-ogy and -gist (French / Latin): biology, biologist, archeology, archaeologist, etc
-gyn- (meaning "woman", from Greek): misogyny, androgyny, gynoid, etc
Exceptions:
gynecologist, gibbon ...and a favorite topic of debate: giga-, where the logical (heh there's another one from French) pronunciation is "jiga", however the hard version is heard more often.
Back to GIF: both ways of pronouncing it are correct, and indeed I have heard both styles. Although anecdotally, the soft version is used more often by people over 35-40.