In a gun fight? Want to win? Pay attention to how the James-Younger gang was defeated in Northfield, Minnesota on September 7, 1876 (citation, full article here).
The James-Younger gang cased Northfield before hitting the bank there. The gang was mainly armed with six-shot revolvers, which were in reality only five-shot revolvers because the firing mechanism of the day did not allow the user to carry the hammer down on a live cartridge. To this day, cowboy-action shooters only load five for safety, though new Ruger cowboy gun clones have safer frame-mounted firing pins and transfer bars.
Back on point, the gang members had maybe two or three handguns, which only held five shots and were painfully slow to reload (the Schofield style revolvers were faster to reload though). When the gang actually entered the bank, a teller refused to open the safe and was killed for his trouble. The residents rather resented the attempted robbery and cold-blooded murder, so they went on the offensive. But not with handguns.
One A.R. Manning used a single shot rifle to kill a horse (why not?), wound Cole Younger, and kill William Chadwell. Henry Wheeler grabbed "an old army carbine" (likely a Sharps single shot carbine) wounded Bob Younger, and killed Clell Miller. The residents finished the fight by dispatching possies which in total numbered around 2000 men.
William Chadwell (left) and Clell Miller (right) "pose" for their last photos. Note the solid heart shot on Chadwell, and the hole in the top of Miller's head. Those Minnesota farmers could shoot, eh?
The James and Younger brothers were deadly with their handguns, so why were they trounced by a bunch of farmers and businessmen? Well, the reasons are many, but two big points come to mind: 1) The rifle is MUCH more powerful than any handgun. Even today, the hyper-magnum revolvers only nudge into light or medium rifle muzzle energy. And in my opinion, they are still slower and less accurate than a rifle from most practical positions. 2) Rifles are easier to shoot at distance than handguns. While they aren't necessarily *easy* to shoot, a mediocre rifleman should be able to make hits at much longer ranges than an above average pistolero. Considering ballistics of the day, a rifle could be expected to make hits (in the hands of your average citizen) at 200 yards or better. A long-barreled revolver of the day, in the hands of a skilled marksman (say, Wild Bill Hickok) could kill a man at up to 75 yards with a carefully (NOT under fire) aimed shot. Add in the stress of a battle, a bucking horse, and a dirty bore, and maybe we should reel that range back in to 15 or 25 yards.
So, conservatively (and that's the way I prefer to do things...), the kind folks of Northfield had nearly double the range of the James-Younger boys, and their rifles hit with more authority. In short, the armed citizens who responded to the robbery gave themselves every advantage. Only a fool would go toe-to-toe with a professional gunslinger. However, an accomplished rifleman would stand a chance if he fought his fight--with aimed fire at distance. The point? When you can do so, go for the long gun. Never fight fair!
I should add that while this article focuses on the rifle, the shotgun is also quite an awesome tool for repelling robbers--particularly for urbanites who need to be concerned with over-penetration. I use steel BB shot (brand doesn't matter much to me, but I like Winchester and Federal) in my 12ga Benelli Nova when in the city, and Centurion Multi-Defense or whatever 00 buckshot I can find cheap when I'm in the country. I sometimes load slugs if I think big mean nasties are in the 'hood (cougars, coyotes, escaped prisoners, insurance salesmen, Jehova's Witnesses, etc.). The shotgun is, in my opinion, the most versatile tool available to civilians. It can be loaded for anything, mouse to moose, is easy to use, and can be quite accurate out to 100 yards.
Now, I know that there will be some situations where you may not have the opportunity to grab a shotgun or rifle. Say you get mugged in the mall parking lot. Well, as nice as it would be to have your AR-15, you'll probably have to settle for your pistol (in my case, an M&P9C). While it's true that "you fight with what you have", I think it is also wise to choose the long gun if the chance presents itself. If you can, go long.