Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:48:27

Certainly has Allah showed to His Messenger the vision in truth. You will surely enter al-Masjid al-Haram, if Allah wills, in safety, with your heads shaved and ˹hair˺ shortened, not fearing ˹anyone˺. He knew what you did not know and has arranged before that a conquest near ˹at hand˺.  

Verily God has fulfilled the vision for His Messenger in all truth: The Messenger of God (s) saw in his sleep, in the year of al-Hudaybiyya before his departure ˹from Medina˺, that he would enter Mecca together with his Companions safely, whereafter they would shave ˹completely˺ or shorten ˹their hair˺. He informed his Companions of this and they rejoiced. But when they set off with him ˹from Medina˺, and the disbelievers impeded them at al-Hudaybiyya such that they had to retreat, which was distressing for them, for some of the hypocrites began to have doubts ˹about the Prophet’s sincerity˺, this ˹verse˺ was revealed (bi’l-haqqi, ‘in all truth’, is semantically connected to sadaqa, ‘fulfilled’, or it is a circumstantial qualifier referring to al-ru’yā, ‘the vision’, and what comes after it is the explanation thereof): ‘You will assuredly enter the Sacred Mosque, God willing — this is ˹said˺ to secure blessings — in safety, to shave your heads, that is, all the hair, or to shorten ˹it˺, ˹to shorten˺ some of the hair (both muhalliqīna and muqassirīna are implied circumstantial qualifiers), without any fear’, ever. So He knew, ˹there to be˺ in the truce, what you did not know, in the way of reconciliation ˹between the believers and the Meccans˺, and assigned ˹you˺ before that, entry, a near victory, namely, the conquest of Khaybar — the vision was fulfilled in the following year.
القرآن:٤٨:٢٧

لَقَدْ صَدَقَ اللَّهُ رَسُولَهُ الرُّؤْيَا بِالْحَقِّ ۖ لَتَدْخُلُنَّ الْمَسْجِدَ الْحَرَامَ إِنْ شَاءَ اللَّهُ آمِنِينَ مُحَلِّقِينَ رُءُوسَكُمْ وَمُقَصِّرِينَ لَا تَخَافُونَ ۖ فَعَلِمَ مَا لَمْ تَعْلَمُوا فَجَعَلَ مِنْ دُونِ ذَٰلِكَ فَتْحًا قَرِيبًا  

{لقد صدق الله رسوله الرؤيا بالحقِّ} رأى رسول الله ﷺ في النوم عام الحديبية قبل خروجه أنه يدخل مكة هو وأصحابه آمنين ويحلقون ويقصرون فأخبر بذلك أصحابه ففرحوا فلما خرجوا معه وصدهم الكفار بالحديبية ورجعوا وشق عليهم ذلك وراب بعض المنافقين نزلت، وقوله بالحق متعلق بصدق أو حال من الرؤيا وما بعدها تفسيرها {لتدخلنِّ المسجد الحرام إنْ شاء الله} للتبرك {آمنين محلقين رءوسكم} أي جميع شعورها {ومقصرين} بعض شعورها وهما حالان مقدرتان {لا تخافون} أبدا {فعلم} في الصلح {ما لم تعلموا} من الصلاح {فجعل من دون ذلك} أي الدخول {فتحا قريبا} هو فتح خيبر وتحققت الرؤيا في العام القابل.