At the LORD's command, the people of Israel left the Sin Desert and moved from place to place. Eventually they came to Rephidim, but there was no water to be found there.
References for Exodus 17:1
So once more the people grumbled and complained to Moses. "Give us water to drink!" they demanded. "Quiet!" Moses replied. "Why are you arguing with me? And why are you testing the LORD?"
But tormented by thirst, they continued to complain, "Why did you ever take us out of Egypt? Why did you bring us here? We, our children, and our livestock will all die!"
Then Moses pleaded with the LORD, "What should I do with these people? They are about to stone me!"
The LORD said to Moses, "Take your shepherd's staff, the one you used when you struck the water of the Nile. Then call some of the leaders of Israel and walk on ahead of the people.
I will meet you by the rock at Mount Sinai. Strike the rock, and water will come pouring out. Then the people will be able to drink." Moses did just as he was told; and as the leaders looked on, water gushed out.
References for Exodus 17:6
Moses named the place Massah -- "the place of testing" -- and Meribah -- "the place of arguing" -- because the people of Israel argued with Moses and tested the LORD by saying, "Is the LORD going to take care of us or not?"
While the people of Israel were still at Rephidim, the warriors of Amalek came to fight against them.
Moses commanded Joshua, "Call the Israelites to arms, and fight the army of Amalek. Tomorrow, I will stand at the top of the hill with the staff of God in my hand."
So Joshua did what Moses had commanded. He led his men out to fight the army of Amalek. Meanwhile Moses, Aaron, and Hur went to the top of a nearby hill.
As long as Moses held up the staff with his hands, the Israelites had the advantage. But whenever he lowered his hands, the Amalekites gained the upper hand.
Moses' arms finally became too tired to hold up the staff any longer. So Aaron and Hur found a stone for him to sit on. Then they stood on each side, holding up his hands until sunset.
As a result, Joshua and his troops were able to crush the army of Amalek.
Then the LORD instructed Moses, "Write this down as a permanent record, and announce it to Joshua: I will blot out every trace of Amalek from under heaven."
Moses built an altar there and called it "The LORD Is My Banner."
References for Exodus 17:15
He said, "They have dared to raise their fist against the LORD's throne, so now the LORD will be at war with Amalek generation after generation."
References for Exodus 17:16