The Messenger of Allah ﷺ set out on a journey while fasting, and continued fasting until he reached Usfan. Then he called for a vessel and drank from it during the day so that people could see him, and he broke his fast until he entered Mecca. He conquered Mecca during Ramadan.Ibn Abbas said, "The Messenger of Allah ﷺ both fasted and broke his fast while traveling, so whoever wishes may fast, and whoever wishes may break his fast."
أخبرنا محمد بن رافع قال حدثنا يحيى بن آدم قال حدثنا مفضل عن منصور عن مجاهد عن طاوس
سافر رسول الله ﷺ فصام حتى بلغ عسفان ثم دعا بإناء فشرب نهارا ليراه الناس ثم أفطر حتى دخل مكة فافتتح مكة في رمضان قال ابن عباس فصام رسول الله ﷺ في السفر وأفطر فمن شاء صام ومن شاء أفطر