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:4663ʿAbdullāh b. Muḥammad > Ḥabbān > Hammām > Thābit > Anas > Abū Bakr

I was in the company of the Prophet ﷺ in the cave, and on seeing the traces of the pagans, I said, "O Messenger of Allah ﷺ If one of them (pagans) should lift up his foot, he will see us." He said, "What do you think of two, the third of whom is Allah?"  

البخاري:٤٦٦٣حَدَّثَنَا عَبْدُ اللَّهِ بْنُ مُحَمَّدٍ حَدَّثَنَا حَبَّانُ حَدَّثَنَا هَمَّامٌ حَدَّثَنَا ثَابِتٌ حَدَّثَنَا أَنَسٌ قَالَ حَدَّثَنِي أَبُو بَكْرٍ ؓ قَالَ

كُنْتُ مَعَ النَّبِيِّ ﷺ فِي الْغَارِ فَرَأَيْتُ آثَارَ الْمُشْرِكِينَ قُلْتُ يَا رَسُولَ اللَّهِ لَوْ أَنَّ أَحَدَهُمْ رَفَعَ قَدَمَهُ رَآنَا قَالَ مَا ظَنُّكَ بِاثْنَيْنِ اللَّهُ ثَالِثُهُمَا