Hitler did this by being bold enough to try it. If the French had resisted, the Germans would have had to retreat. But the French did not know this and did nothing to stop the remilitarization.
In remilitarizing the Rhineland, Hitler did not have to fight. There were no foreign troops in the area. It is just that Germany was not supposed to have any troops there. After some consideration, Hitler sent three battalions of troops across the Rhine into the Rhineland. The French Army massed on the border between France and the Rhineland, but did not enter to try to prevent the militarization.
Hitler accomplished this, then, simply by being bold enough to send troops into the forbidden area. He got away with his gamble and the Rhineland was remilitarized.