This time, in response to David"s prayer, the Lord prescribed an attack from the rear ( 2 Samuel 5:23). The sound of marching in the treetops among which the Israelites took cover (wind?) would be the sign that the Lord was going before his army to strike the enemy ( 2 Samuel 5:24; cf. Acts 2:2). The name "Gibeon" replaces "Geba" in the text in the parallel account of this battle ( 1 Chronicles 14:16). Gibeon is probably correct. If David pursued the Philistines through the Aijalon valley, he probably went through Gibeon northwest of Jerusalem rather than Geba to the northeast. Gezer stood in the Shephelah14miles west of Gibeon on the Philistine border. [source][source][source]
These victories cleared the Philistines from the hill country of Judah and Benjamin, and made it possible for David to establish a secure capital in Jerusalem. Had he not defeated them, his reign would have gotten off to a much weaker start. Saul had also begun his reign by defeating the Philistines ( 1 Samuel 7). [source][source][source]
"In the present context 2 Samuel 5:17-25 depict two encounters between David and the Philistines, which apparently brought to an end the Philistine domination of Palestine (see also 2 Samuel 8:1). In view of the book as a whole, it seems that the war with the Philistines was more prolonged, but the editor had chosen only these two select illustrations to sketch the main course of events. Perhaps, just as Israel had been defeated twice by the Philistines ( 1 Samuel 4 , 31) so also the Philistines were twice routed by David." [1][source]