Good question, and one that many learners ask.
What's more - the answer is not all that definitive.
One general rule is that the G followed by an E, I, or Y is usually pronounced as a J.
But there are several notable exceptions. Examples : gem, genuine, gist, gymnast
Exceptions : gecko, get, giblets, gynecology
Read more: How do you pronounce g As g or j
My best advice is to rely on your dictionary's pronunciation guide when you are not sure.
Student or Learner