The five-speed manual transmission is fairly standard on cars today. Internally, it looks something like this:
There are three forks controlled by three rods that are engaged by the shift lever. The shift lever has a rotation point in the middle. When you push the knob forward to engage first gear, you are actually pulling the rod and fork for first gear back.
When you move the shifter left and right you are engaging different forks (and therefore different collars). Moving the knob forward and backward moves the collar to engage one of the gears.
Idler Gear or Reverse Gear-
Idler gear is a small gear (purple) and is slid between red and blue gear. At all times, the blue reverse gear in this diagram is turning in a direction opposite to all of the other blue gears. The idler has teeth which mesh with both gears, and thus it couples these gears together and reverses the direction of rotation without changing the gear ratio.