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.
bukhari:1729ʿAbdullāh b. Muḥammad b. Asmāʾ > Jūwayriyah b. Asmāʾ > Nāfiʿ > ʿAbdullāh

The Prophet ﷺ and some of his companions got their heads shaved and some others got their hair cut short.  

البخاري:١٧٢٩حَدَّثَنَا عَبْدُ اللَّهِ بْنُ مُحَمَّدِ بْنِ أَسْمَاءَ حَدَّثَنَا جُوَيْرِيَةُ بْنُ أَسْمَاءَ عَنْ نَافِعٍ أَنَّ عَبْدَ اللَّهِ قَالَ

حَلَقَ النَّبِيُّ ﷺ وَطَائِفَةٌ مِنْ أَصْحَابِهِ وَقَصَّرَ بَعْضُهُمْ  


See similar narrations below:

Collected by Bukhārī
bukhari:4411ʿUbaydullāh b. Saʿīd > Muḥammad b. Bakr > Ibn Jurayj > Mūsá b. ʿUqbah > Nāfiʿ > Ibn ʿUmar

During Hajjat-ul-Wadaʿ, the Prophet ﷺ and some of his companions got their heads shaved while some of his companions got their head-hair cut short.  

البخاري:٤٤١١حَدَّثَنَا عُبَيْدُ اللَّهِ بْنُ سَعِيدٍ حَدَّثَنَا مُحَمَّدُ بْنُ بَكْرٍ حَدَّثَنَا ابْنُ جُرَيْجٍ أَخْبَرَنِي مُوسَى بْنُ عُقْبَةَ عَنْ نَافِعٍ أَخْبَرَهُ ابْنُ عُمَرَ

أَنَّ النَّبِيَّ ﷺ حَلَقَ فِي حَجَّةِ الْوَدَاعِ وَأُنَاسٌ مِنْ أَصْحَابِهِ وَقَصَّرَ بَعْضُهُمْ