Against Terran specifically, you should attack the SCV as it is building since that is the weak link. It will go down quickly and then you will not have to worry about it any more.
Zerg players using this tactic will often cancel the extractor as it gets close to finishing and start it over again, to maximize how annoying it is since the health of the extractor resets to maximum every time. In this case, at least he cannot grab both geysers.
Protoss players can build assimilators on both geysers fairly easily, but it's at a cost of 75 minerals each so you will be able to get out an extra zealot and a half that he won't have access to, giving you a slight army advantage first until you get the assimilators away.
Overall, the main thing you have to do against this kind of tactic is make sure that it doesn't affect your macro. Keep building probes nonstop to mine minerals as fast as possible, and possibly go for a 2-gateway or more build to pump out zealots as fast as possible until you've dealt with the issue.
The most important thing to realize is that 3 workers per mineral is the max you would want. It is not necessarily optimal however. The third worker is not as effective as the first 2. Once you have more than 2 workers, one of them will always be "hanging around" waiting for its turn to be useful. Therefore, if you have an expo with less than 2 workers per patch, you would do better to move some workers there. You will get more minerals per minute by having 2 workers per patch at your main and 1 per patch at your expo than you would with 3 workers per patch at your main.
With that in mind, here are some answers:
How to keep track of how many you have at a specific base?
Make sure all your mineral patches and gas geysers are visible on the screen. Now double click on one of your workers. This will select all your workers. At the bottom middle of your screen you'll see wireframes of all of them, 8 per row. if you have 3 rows full, that's 24 workers, which is a decently saturated base. "Full" saturation would be about 24 on minerals and 6 on gas, or 30. But if you have an expo, you're better off moving some of them... (Note that MULEs do not conflict with SCV's for mining time, so they should not factor into your counts.)
When you expand, should you build workers from that base or transfer?
This depends on the situation. If your expo is far away from your main, and there are potentially enemy forces in between, then transferring is probably a bad idea. If you have more than 2 workers per patch in your main, and your natural is nearby and well defended, then transferring makes sense. In my experience, Zerg players usually expand before they have much more than 2 workers per patch, while a 1 base terran or protoss will often build up 30 workers on one base before expanding.
**Rebuilding after some being killed **
I'm not sure what the question is here - you can just rebuild them like you normally build them.
Transferring when minerals run out
There is no automatic way to have workers move to an expansion when minerals or gas run out. However, you can listen for the voice that says "mineral patch depleted" and start transferring them. You can also look for the idle worker icon that pops up on the lower left hand side of your screen, that will alert you to a worker who is not doing anything.
Race Specific Tidbits
Protoss can chronoboost workers to help get an economy up and running, or recover from an attack.
Terrans can get by with less SCVs if they have a lot of orbital commands to summon MULEs with.
Terrans can load SCV's into command centers, then fly them to a new base.
Zerg players need to remember to build more drones to replace drones used to build buildings.
Best Answer
I found what I think is actually the best answer while browsing the Team Liquid forums:
The most efficient way is to select any 3 workers, right click on the gas, then immediately hit C (return cargo). Workers that are holding minerals will drop off their minerals, and then proceed to gas. Meanwhile, workers without minerals will head straight for the gas!