Heat pumps replacing existing gas furnaces, the predominant heating system in Europe, are crucial for achieving global CO2 2 emission reduction targets. Previous studies have simulated this reduction potential for a few buildings, revealing substantial variations in results. Moreover, additional CO2 2 emission reductions are proven to be possible with photovoltaic installations and battery energy storage systems. However, as these come with high investment costs, the question remains whether these are economically viable. Moreover, as the building stock shows a high degree of diversity and the heat demand is dependent on the annual weather conditions, the CO2 2 emission reduction and the cost-effectiveness of incorporating photovoltaics or battery systems should be analyzed for all buildings in a city over multiple years. In this paper, we address these questions by utilizing a digital twin of a German city encompassing all residential buildings, capturing the diversity of the building stock. Our findings indicate that retrofitting heat pumps, only considering the heating system, reduces average annual CO2 2 emissions by 18.6% to 38.9% across different years. The variance in emission reduction, up to 1.6 percentage points, is not year-dependent. The maximum CO2 2 reduction on the building level is achieved by combining heat pumps with photovoltaic and battery systems for most buildings, averaging a 31.2% to 43.6% reduction even in a Central European climate with low winter photovoltaic generation. Economically, a heat pump retrofit with photovoltaic installation emerges as the most beneficial setting for most buildings in the studied city, effectively balancing cost and emission reduction.