This paper presents an analytical framework to develop a hierarchical energy management system (EMS) for energy sharing among neighbouring households in residential microgrids. The houses in residential microgrids are categorized into three different types, traditional, proactive and enthusiastic, based on the inclusion of solar photovoltaic (PV) systems and battery energy storage systems (BESSs). Each of these three houses has an individual EMS, which is defined as the primary EMS. Two other EMSs (secondary and tertiary) are also considered in the proposed hierarchical energy management framework for the purpose of effective energy sharing. The intelligences of each EMS are presented in this paper for the purpose of energy sharing in a residential microgrid along with the priorities. The effectiveness of the proposed hierarchical framework is evaluated on a residential microgrid in Australia. The analytical results clearly reflect that the proposed scheme effectively and efficiently shares the energy among neighbouring houses in a residential microgrid.