Sahih Muslim , Book 29, Hadith 5649 (USC-MSA) ⓘ
Abu Musa reported Allah's Messenger as saying: I dreamt (while asleep) that I was about to migrate from Mecca to a land abounding in palm trees and I guessed that it would be Yamama or Hajar, but it was the city of Yathrib (the old name of Medina), and I saw in this dream of mine that I was brandishing a sword and its upper end was broken and this is what fell (in the form of misfortune to the believers on the Day of Uhud). I brandished (the sword) for the second time and it became all right and this is what came to be true when Allah granted us victory and solidarity of the believers. And I saw therein cows also and Allah is the Doer of good. These meant the group from amongst the believers on the Day of Uhud and the goodness which Allah brought after that and the reward of attestation of his Truth which Allah brought to us after the Day of Badr.
حَدَّثَنَا أَبُو عَامِرٍ عَبْدُ اللَّهِ بْنُ بَرَّادٍ الأَشْعَرِيُّ، وَأَبُو كُرَيْبٍ مُحَمَّدُ بْنُ الْعَلاَءِ - وَتَقَارَبَا فِي اللَّفْظِ - قَالاَ حَدَّثَنَا أَبُو أُسَامَةَ، عَنْ بُرَيْدٍ، عَنْ أَبِي بُرْدَةَ، جَدِّهِ عَنْ أَبِي مُوسَى، عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ " رَأَيْتُ فِي الْمَنَامِ أَنِّي أُهَاجِرُ مِنْ مَكَّةَ إِلَى أَرْضٍ بِهَا نَخْلٌ فَذَهَبَ وَهَلِي إِلَى أَنَّهَا الْيَمَامَةُ أَوْ هَجَرُ فَإِذَا هِيَ الْمَدِينَةُ يَثْرِبُ وَرَأَيْتُ فِي رُؤْيَاىَ هَذِهِ أَنِّي هَزَزْتُ سَيْفًا فَانْقَطَعَ صَدْرُهُ فَإِذَا هُوَ مَا أُصِيبَ مِنَ الْمُؤْمِنِينَ يَوْمَ أُحُدٍ ثُمَّ هَزَزْتُهُ أُخْرَى فَعَادَ أَحْسَنَ مَا كَانَ فَإِذَا هُوَ مَا جَاءَ اللَّهُ بِهِ مِنَ الْفَتْحِ وَاجْتِمَاعِ الْمُؤْمِنِينَ وَرَأَيْتُ فِيهَا أَيْضًا بَقَرًا وَاللَّهُ خَيْرٌ فَإِذَا هُمُ النَّفَرُ مِنَ الْمُؤْمِنِينَ يَوْمَ أُحُدٍ وَإِذَا الْخَيْرُ مَا جَاءَ اللَّهُ بِهِ مِنَ الْخَيْرِ بَعْدُ وَثَوَابُ الصِّدْقِ الَّذِي آتَانَا اللَّهُ بَعْدُ يَوْمَ بَدْرٍ " .
also referenced under: Book 42, Hadith 38 (In-Book) & Hadith 2272 (Reference)