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:4:84

So fight, ˹O Muhammad˺, in the cause of Allah; you are not held responsible except for yourself. And encourage the believers ˹to join you˺ that perhaps Allah will restrain the ˹military˺ might of those who disbelieve. And Allah is greater in might and stronger in ˹exemplary˺ punishment.  

So fight, O Muhammad (s), in the way of God; you are charged only with yourself, so do not be concerned with their failing to join you, the meaning being: fight, even if you are on your own, for you have been promised victory. And urge on the believers, incite them to fight and make them desire it; maybe God will restrain the might, the war, of the disbelievers; God is mightier, than them, and more severe in castigation, in punishment, than them. And so the Messenger of God (s) said: ‘By Him in Whose Hand is my soul, I shall sally forth ˹to fight˺, even if ˹I go˺ alone’. Thereupon, he sallied forth with seventy cavalrymen to the first ˹battle at˺ Badr, where God restrained the might of the disbelievers by casting terror into their hearts and preventing Abū Sufyān from sallying forth, as has already been mentioned in ˹sūrat˺ Āl ‘Imrān ˹Q. 3:151˺.
القرآن:٤:٨٤

فَقَاتِلْ فِي سَبِيلِ اللَّهِ لَا تُكَلَّفُ إِلَّا نَفْسَكَ ۚ وَحَرِّضِ الْمُؤْمِنِينَ ۖ عَسَى اللَّهُ أَنْ يَكُفَّ بَأْسَ الَّذِينَ كَفَرُوا ۚ وَاللَّهُ أَشَدُّ بَأْسًا وَأَشَدُّ تَنْكِيلًا  

(فقاتل) يا محمد (في سبيل الله لا تكلف إلا نفسك) فلا تهتم بتخلفهم عنك المعنى قاتل ولو وحدك فإنك موعود بالنصر (وحرض المؤمنين) حثهم على القتال ورغبهم فيه (عسى الله أن يكف بأس) حرب (الذين كفروا والله أشد بأسا) منهم (وأشد تنكيلا) تعذبيا منهم فقال رسول الله ﷺ : "" والذي نفسي بيده لأخرجن ولو وحدي "" فخرج بسبعين راكبا إلى بدر الصغرى فكف الله بأس الكفار بإلقاء الرعب في قلوبهم ومنع أبي سفيان عن الخروج كما تقدم في آل عمران.