Everybody always says that changing gear is something you figure out when you first learn to ride a motorcycle and then forget all about. The only times you might offer a few thoughts down to your left foot is when you miss a gear, it won't select the next cog or if somethings breaks. Which is just as it should be. On the whole, like using the throttle, clutch or brake levers it should be an instinctive action you don't think too hard about.
But there are things you should at least consider; like what revs are you changing gear at? How quickly do you change up and how much do you blip the throttle? When you change down does the rear wheel lock sometimes? And what's going on inside that gear box each time you shift that gear lever?
The job of a gearbox is to turn the rotating force from your engine into something you can use to propel your motorcycle forwards over a wide speed-range. All gearboxes contain at least two shafts – input and output. Your motorcycle's front sprocket bolts to the output shaft and the input shaft is attached to the clutch, which stops and starts drive when you use the clutch lever.
That's the easy bit. On each of the two shafts you'll find six gears (in a six speed gearbox) – all of which are engaged with each other, thus the name 'constant mesh.' Six different ratios all in mesh shouldn't be able to turn because the gears to turn because the gears will all want to spin at different rates, but one cog from each pair can spin freely.
This removes one problem but creates another, which is where the gear lever comes in. When you click first gear you force the selector drum (a cylinder with wiggly tracks cut into its surface) to rotates one stop. As it rotates the tracks seem to shift side to side (like the flute on a drill-bit seems to move upwards). These tracks move the selector forks inside the gearbox, which are connected to gears that slide from side to side on the shafts.
So when you select a gear, you cause one or more of these sliding gears to move and engage its dogs with the gear next to it (dogs are small bits of metal protruding from the side of the gear and slots are the opposite).
You can lock two gears together and force them to turn as one by engaging dog-to-dog or dog-to-slot. So to pass drive from one shaft to another, one of these gears slides across to lock the freely spinning gear of the ratio you select. Now both cogs from the pair are locked and the output shaft is forced to spin in proportion to the gear ratio.