In Garageband click the loop button.
Then move the yellow ruler bar to where you would like to record a cycle.
Select the track you want to record to and click the record button
Record your takes. When you are done you will have a track that looks something like the image below.
Click the highlighted take count number on the upper left of the recording
You can then select the take you want from the list. You can also delete all unused takes or the selected take.