Umar gave a horse in charity for the sake of Allah . He later found it being sold and wanted to buy it back. He came to the Messenger of Allah ﷺ and asked his permission to do so.The Messenger of Allah ﷺ said, "Do not take back what you have given in charity."
أخبرنا محمد بن عبد الله بن المبارك قال أنبأنا حجين قال حدثنا الليث عن عقيل عن ابن شهاب عن سالم بن عبد الله أن
أن عمر تصدق بفرس في سبيل الله عز وجل فوجدها تباع بعد ذلك فأراد أن يشتريه ثم أتى رسول الله ﷺ فاستأمره في ذلك فقال رسول الله ﷺ لا تعد في صدقتك
Bukhari narrated it, Zakat, Chapter "Is it permissible to buy back one's charity? There is no harm in buying it," etc., no. 1489, from the hadith of Layth bin Saad, and Muslim (see the previous hadith), from the hadith of Ibn Shihab Zuhri, with the same wording. It is also found in Al-Kubra, no. 2399.