Language:
كتاب الجهاد والسير
56  
Fighting for the Cause of Allah (Jihaad)
(110)
Chapter: To give a Bai'a for not to flee during a battle
(110)
باب الْبَيْعَةِ فِي الْحَرْبِ أَنْ لاَ يَفِرُّوا
Sahih al-Bukhari 2961

Narrated Anas:

On the day (of the battle) of the Trench, the Ansar were saying, "We are those who have sworn allegiance to Muhammad for Jihaid (for ever) as long as we live." The Prophet (ﷺ) replied to them, "O Allah! There is no life except the life of the Hereafter. So honor the Ansar and emigrants with Your Generosity."

حَدَّثَنَا حَفْصُ بْنُ عُمَرَ، حَدَّثَنَا شُعْبَةُ، عَنْ حُمَيْدٍ، قَالَ سَمِعْتُ أَنَسًا ـ رضى الله عنه ـ يَقُولُ كَانَتِ الأَنْصَارُ يَوْمَ الْخَنْدَقِ تَقُولُ نَحْنُ الَّذِينَ بَايَعُوا مُحَمَّدَا عَلَى الْجِهَادِ مَا حَيِينَا أَبَدَا فَأَجَابَهُمُ النَّبِيُّ صلى الله عليه وسلم فَقَالَ اللَّهُمَّ لاَ عَيْشَ إِلاَّ عَيْشُ الآخِرَهْ فَأَكْرِمِ الأَنْصَارَ وَالْمُهَاجِرَهْ
Reference : Sahih al-Bukhari 2961
In-book reference : Book 56, Hadith 172
USC-MSA web (English) reference : Vol. 4, Book 52, Hadith 208
  (deprecated numbering scheme)
Sahih al-Bukhari 2962, 2963

Narrated Mujashi:

My brother and I came to the Prophet (ﷺ) and I requested him to take the pledge of allegiance from us for migration. He said, "Migration has passed away with its people." I asked, "For what will you take the pledge of allegiance from us then?" He said, "I will take (the pledge) for Islam and Jihad."

حَدَّثَنَا إِسْحَاقُ بْنُ إِبْرَاهِيمَ، سَمِعَ مُحَمَّدَ بْنَ فُضَيْلٍ، عَنْ عَاصِمٍ، عَنْ أَبِي عُثْمَانَ، عَنْ مُجَاشِعٍ ـ رضى الله عنه ـ قَالَ أَتَيْتُ النَّبِيَّ صلى الله عليه وسلم أَنَا وَأَخِي فَقُلْتُ بَايِعْنَا عَلَى الْهِجْرَةِ‏.‏ فَقَالَ ‏"‏ مَضَتِ الْهِجْرَةُ لأَهْلِهَا ‏"‏‏.‏ فَقُلْتُ عَلاَمَ تُبَايِعُنَا قَالَ ‏"‏ عَلَى الإِسْلاَمِ وَالْجِهَادِ ‏"‏‏.‏
Reference : Sahih al-Bukhari 2962, 2963
In-book reference : Book 56, Hadith 173
USC-MSA web (English) reference : Vol. 4, Book 52, Hadith 208
  (deprecated numbering scheme)