Qaza reported,

I came to Abu Saeed Khudri رضي الله عنه when many people were gathered around him. When the crowd dispersed, I said, "I am not going to ask you about what these people were asking you."I asked him about fasting while traveling.He said, "We traveled with the Messenger of Allah ﷺ toward Makkah while fasting. We stopped at a place, and the Messenger of Allah ﷺ said, 'You are drawing close to your enemy, and breaking the fast will give you more strength.' It was a concession, so some of us fasted and some of us broke the fast.Then we stopped at another place, and he said, 'You will meet your enemy in the morning, and breaking the fast will give you more strength, so break your fast.' This was a firm command, so we broke our fast."Then he said, "Later, you would see us fasting with the Messenger of Allah ﷺ while traveling."

Azami 4602

Sahih

عن قزعة، قال

أتيت أبا سعيد الخدري رضي الله عنه وهو مكثور عليه، فلما تفرق الناس عنه، قلت: إني لا أسألك عما يسألك هؤلاء عنه. سألته عن الصوم في السفر؟ فقال: سافرنا مع رسول الله ﷺ إلى مكة ونحن صيام. قال: فنزلنا منزلا، فقال رسول الله ﷺ: إنكم قد دنوتم من عدوكم والفطر أقوى لكم. فكانت رخصة فمنا من صام، ومنا من أفطر. ثم نزلنا منزلا آخر، فقال: إنكم مصبحوا عدوكم، والفطر أقوى لكم، فأفطروا. وكانت عزمة، فأفطرنا. ثم قال: رأيتنا نصوم مع رسول الله ﷺ بعد ذلك في السفر.

الأعظمي 4602صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Fasting
Chapter
What is permitted and what is not permitted for the fasting person
Section
Recommendation of breaking the fast while traveling in order to gain strength for fighting, serving one's companions, and similar matters
Numbering
Jami al-Kamil 4602 (2nd edition)
Azami 4602