I've come across that problem before. You have trigger shifters (Shimano brand: Rapid Fire) and the mechanism relies on a similar escapement mechanism found in clocks. Your unit is dirty and the grease has become too hard to allow the pawl to move freely and keep the barrel stationary.
It needs cleaning.
You need to remove the cover from the flappy lever system. It is held on with two or three tiny Philips-head screws. Be careful to only remove the little screws that hold the plastic cover on, not anything that holds the mechanism in place.
Once you have the cover off, the mechanism will be exposed. Squirt the hell out of it with one fof the many lubricant/solvent sprays. These are recognisable by cans with long plastic nozzles and fierce-sounding lab code-names like X-25 or GT-40 or WR-82.
Click away at the gears whilst spraying and cleaning. Once the mechanism is clean and moves freely, apply a little bit of light grease to it. Something like Vaseline will also work.
Replace the cover and go for a ride and drink a beer.
If you are uncertain, post a photo of the underside of the flappy gearbox and we'll tell you which screws to remove.