Narrated Ibn 'Umar:
That a woman was found killed in one of the expeditions of the Messenger of Allah (ﷺ), so the Messenger of Allah (ﷺ) rebuked that, and he prohibited killing women and children.
There are narrations on this topic from Buraidah and Rabah - and they say he was Riyah - bin Ar-Rabi', Al-Aswad bin Sari', Ibn 'Abbas, and As-Sa'b bin Jaththamah.
[Abu 'Eisa said:] This Hadith is Hasan Sahih. This is acted upon according to some of the people of knowledge among the Companions of the Prophet (ﷺ) and others. They disliked killing women and children. This is the view of Sufyan Ath-Thawri and Ash-Shafi'i.
Some of the people of knowledge made an exception for killing the women who had children with them during night attacks, this is the view of Ahmad and Ishaq, they permitted it in night attacks.