كتاب الحج
15  
The Book of Pilgrimage
(55)
Chapter: Shaving the head is preferrable to cutting the hair, although cutting the hair is permissible
(55)
باب تَفْضِيلِ الْحَلْقِ عَلَى التَّقْصِيرِ وَجَوَازِ التَّقْصِيرِ ‏‏
Sahih Muslim 1301 a

'Abdullah reported that Allah's Messenger (ﷺ) got his head shaved (after slaughtering the sacrificial animal on the 10th of Dhu'l-Hijja), and so did a group of Companions, while some of them got their hair clipped. Abdullah said:

Allah's Messenger (may peace'be upon him) observed once or twice:" May Allah have mercy upon those who get their heads shaved." And he also said:" Upon those too who got their hair clipped."
وَحَدَّثَنَا يَحْيَى بْنُ يَحْيَى، وَمُحَمَّدُ بْنُ رُمْحٍ، قَالاَ أَخْبَرَنَا اللَّيْثُ، ح وَحَدَّثَنَا قُتَيْبَةُ، حَدَّثَنَا لَيْثٌ، عَنْ نَافِعٍ، أَنَّ عَبْدَ اللَّهِ، قَالَ حَلَقَ رَسُولُ اللَّهِ صلى الله عليه وسلم وَحَلَقَ طَائِفَةٌ مِنْ أَصْحَابِهِ وَقَصَّرَ بَعْضُهُمْ ‏.‏ قَالَ عَبْدُ اللَّهِ إِنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ ‏ "‏ رَحِمَ اللَّهُ الْمُحَلِّقِينَ - مَرَّةً أَوْ مَرَّتَيْنِ ثُمَّ قَالَ - وَالْمُقَصِّرِينَ ‏"‏ ‏.‏
Reference : Sahih Muslim 1301a
In-book reference : Book 15, Hadith 348
USC-MSA web (English) reference : Book 7, Hadith 2983
  (deprecated numbering scheme)