قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ : " لَوْلا الْهِجْرَةُ لَكُنْتُ امْرَءًا مِنَ الأَنْصَارِ، وَلَوْ يَنْدَفِعُ النَّاسُ فِي شُعْبَةٍ أَوْ فِي وَادٍ وَالأَنْصَارُ فِي شُعْبَةٍ لانْدَفَعْتُ مَعَ الأَنْصَارِ فِي شِعْبِهِمْ "
And the Messenger of Allah, peace and blessings be upon him, said: "If it were not for the virtue of migration, I would certainly have been one of the Ansar, and if people were to walk in a mountain pass or a valley and the Ansar were to walk in another mountain pass, I would walk with the Ansar in their mountain pass."
Related hadith on this topic