The Prophet ﷺ said: Our Lord Most High is pleased with a man who fights in the path of Allah, the Exalted; then his companions fled away (i.e. retreated). But he knew that it was a sin (to flee away from the battlefield), so he returned, and his blood was shed. Thereupon Allah, the Exalted, says to His angels: Look at My servant; he returned seeking what I have for him (i.e. the reward), and fearing (the punishment) I have, until his blood was shed. (Using translation from Abū Dāʾūd 2536)
قَالَ رَسُولُ اللَّهِ ﷺ عَجِبَ رَبُّنَا ﷻ مِنْ رَجُلٍ غَزَا فِي سَبِيلِ اللَّهِ فَانْهَزَمَ أَصْحَابُهُ فَعَلِمَ مَا عَلَيْهِ وَرَجَعَ حَتَّى أُهْرِيقَ دَمُهُ فَيَقُولُ اللَّهُ تَبَارَكَ وَتَعَالَى لِمَلَائِكَتِهِ انْظُرُوا إِلَى عَبْدِي رَجَعَ رَغْبَةً فِيمَا عِنْدِي وَشَفَقَةً مِمَّا عِنْدِي حَتَّى أُهْرِيقَ دَمُهُ