One version in Sahih al-Bukhari says: 'The Hour will not come until you fight the Jews, until the stone behind which a Jew is hiding says, O Muslim, there is a Jew behind me, so kill him.' Another version in Sahih al-Bukhari, narrated by Ibn Umar, begins, 'The Jews will fight you, and you will be given power over them.' Sahih Muslim has a similar report, in which a Jew hiding behind a stone or a tree is given away by it, except for the gharqad tree, which stays silent because it is described as a tree of the Jews. It has been quoted by people who want to portray Islam as hateful, and by some militant groups to justify violence, and an honest answer should not avoid it.
How should it be read? First, by its wording. It is a statement about the future, introduced by 'the Hour will not come until', and the second version says that it is the Jews who will fight the Muslims. Al-Bukhari placed that version in his chapter on the signs of prophethood and the other in his chapter on fighting the Jews. Scholars differ about who exactly is meant and when and how it will happen, and Allah knows best. A prediction of what will happen is not in itself a command. The rules of fighting come from the Quran and the Prophet's practice, which forbid killing women, children and people under a covenant.
Against this stand the clear texts. The Quran says that Allah does not forbid kindness and justice towards those who do not fight you over religion, and that hatred of a people must never make you unjust. It says that to kill a person unjustly is like killing all of humanity. The Prophet ﷺ said that whoever kills a person under a covenant will not smell the fragrance of Paradise. For this reason many Muslims reject the use of this hadith to justify hatred or violence, and ask that the whole of the Prophet's teaching be read together.