If the damage is more severe, such as a gash or a large hole that a patch won't cover, cut the tube at the damaged area and tie a knot in each end. Or, if you have two zip-ties, cinch them down as tight as you can on either side of the tear. Remount the tire, inflate it and continue on your way. The ride will be bumpy, but the rim will be protected if you use enough filler material. If you have a flat tire but forgot to bring your tire levers, remove the quick-release skewers from your hubs and pry the tire off with the levers.
Aggressive riding can yield unpleasant results sometimes.
Torn sidewalls usually happen while riding hard over rocky terrain, or after a puncture has occurred and the tire deflates. If you can re- pair or replace the tube you should then patch up the gash in the tire sidewall with anything strong enough to keep the tube from herniating out through the hole. Dollar bills, thick leaves, a business card, duct tape or a piece of inner tube will usually suffice. The rear derailleur is an especially vulnerable component. It's almost sure to get bent or broken if you lay it over on the right side, and roots or low tree branches can catch on it as you ride by, which could even tear it off the frame.