Research indicates that the earliest stages of Proto-Indo-European had two genders (animate and inanimate), as did Hittite, the earliest attested Indo-European language. The classification of nouns based on animacy and inanimacy and the lack of gender are today characteristic of Armenian. According to the theory, the animate gender, which (unlike the inanimate) had independent vocative and accusative forms, later split into masculine and feminine, thus originating the three-way classification into masculine, feminine and neuter.
Many Indo-European languages retained the three genders, including most Slavic languages, Latin, Sanskrit, Ancient and Modern Greek, German, Icelandic, Romanian and Asturian (two Romance language exceptions). In them, there is a high but not absolute correlation between grammatical gender and declensional class. Many linguists believe that to be true of the middle and late stages of Proto-Indo-European.
As for the evolution of grammatical gender within this family :
Interesting!