Read this passage and open each verse for the full verse feed and commentary tools.
22And the Philistines came up yet again, and spread themselves in the valley of Rephaim. 23And when David inquired of Jehovah, he said, Thou shalt not go up: make a circuit behind them, and come upon them over against the mulberry-trees. 24And it shall be, when thou hearest the sound of marching in the tops of the mulberry-trees, that then thou shalt bestir thyself; for then is Jehovah gone out before thee to smite the host of the Philistines. 25And David did so, as Jehovah commanded him, and smote the Philistines from Geba until thou come to Gezer.
2 Samuel 5:22-25 (ASV)