At the end of the day there was victory and God told Moses to write down what had happened and read it in Joshua's hearing. God was thinking ahead to the time when Moses would be gone and Joshua would be called upon to take over leadership of God's chosen people. Joshua would be the one to cross the Jordan River into Canaan (the Promised Land) and defeat Jericho. He would have plenty of battles ahead of him and God wanted him to remember back to this one and the victory God had given them.
Instead of raising a flag, Moses built an altar because in those times, an altar was often used as a place of remembering or marking an important event. This is where Moses called God Jehovah Nissi because he understood the revelation that God himself is our banner, our victory. He is the one who wins our battles. He still does that by the way. When Moses wrote that story down for Joshua, he was also writing it down for our benefit so that we will remember it as we go into battle. How do we know that?
There is an interesting thing that God says when he tells Moses to write down the story. God says that he "…will utterly blot out the remembrance of Amalek from under heaven." (verse 14b) That means that this enemy would not rise again - he was defeated UTTERLY. In verse 16, however, Moses says; "…the Lord has sworn: the Lord will have war with Amalek from generation to generation." How is it that God is saying the enemy was completely defeated and yet that there would be future wars with Amalek in future generations?
Amalek in this story represents our enemy, Satan, who is active against God's people in all generations. Even though the literal "Amalek" at that time was completely defeated by Israel's army, other Amaleks would rise up against Israel and on down to you and me in our own generation. When you gather under Jehovah Nissi as your banner, trust him that the outcome of your battle will be the same as it was for Moses and Joshua at Rephidim. God is saying there will always be war; don't be surprised by it. He is also saying he is always the winner.