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!
gaming.stackexchange.com/users/8/Emmett
It depends on what you mean by "not lose minerals"
If you do it manually, you'll take about 2 seconds, and you can lose zero minerals.
If you don't do it manually, statistically, you'll have one who is walking to gather (A), one who is walking back with minerals in hand (B), and one who is in the middle of gathering (C).
(As they spend about a third of their time on each task) Option 1: If you're in the middle of the battle and need the absolute most amount of time you just have them all start going to the gas: (A) will not lose any minerals (B) will lose 5 minerals (the minerals in his hands at the time) (C) will "lose" (on average) 2.5 minerals.
(it isn't really "lost" because the next guy will get it, but you've lost the time it took for that worker to start, but not finish mining) Option 2:If you have a brief instant of reprieve, but need to get back on the battlefield, you can save 5 minerals from option 1, by sending (B) back to the base.
The quickest way to do that is by ordering "return with goods".
This is better then sending them all back to the base, because only the one with minerals will run back.
Immediately after issuing the "return with goods / return cargo" command, shift right click on the geyser, and that will queue a command to the geyser, which for the other two will be executed instantly.
This can be done in one instant, because the return with goods command can be issued by the keyboard hand, while the mouse hand will be moving to issue the command to the geyser.
Option 3
:If you have a little bit longer, select only those that are going back to mining, that way you lose no minerals at all, nor even time wasted mining.
It does depend on how urgent you need to get back to the battle, but if the battle is so important that it can't be delayed by a couple seconds, the gas can probably wait.
gaming.stackexchange.com/users/126/McKay
What I usually do is quickly grab the group that is nearest to the gas
, shift click the excess workers then shift click my 3 to the Nexus/Command Center/Hatchery then shift click to the gas.
This will tell them to drop off any minerals they have (no wasting) and then go mine gas. shift + click = queueing commands.
So you are telling the worker to finish mining -> drop off minerals -> mine gas
gaming.stackexchange.com/users/2091/Mark
Usually, when your gas is depleted, naturally, you would have idle workers.
Here is what I do: On top of Mark's answer, if you have idle workers then you can press F1 to select an idle worker.
However, if you hold CTRL + F1 then it will select ALL idle workers.
So assuming you do not have any other idle workers, and when your gas is depleted then you can just press CTRL + F1 and select the 3 idle workers.
gaming.stackexchange.com/users/2562/Doug
What I do is set the command center's rally point to the refinery and build 3 more.
I don't know if this counts as "sacrificing materials", but in my opinion, you can never have enough workers.
gaming.stackexchange.com/users/14/juan
The easiest manual way to do it would be to just select three workers and get Ctrl+1-9 them.
This will then bind them to a key.
Quickly click on the nearest base to the workers, this will allow them to drop any minerals that they are carrying.
If your battling and cant watch them, when you see the "Workers not working" button appear on the left hand side of your screen press 1-9 depending on what HotKey you selected and then click on your refinery.
This would result in no loss in minerals, via them being dropped.
gaming.stackexchange.com/users/2708/Vibralux
I usually just draw a small rectangle close to the command center/hatch/nexus and keep the mouse button down until there are at least workers 3 in it.
Then i quickly right-click on the cc/hatch/nexus in case they carried anything
and then i send them to the refinery.
If i got more than 3 (usually i don't, but sometimes i get a fourth worker)
then after sending all to the refinery i pick the excess workers in the selected units list and send them to work on the minerals again.
This takes roughly 1-3 seconds, depending on how many workers you have and how good you are at figuring out where the 3 workers will be easiest to capture.
It's easier and faster to rectangle-select more and remove the unnecessary ones than it's to select them one-by-one when they are moving.
gaming.stackexchange.com/users/1978/Morfildur
When my Refinery finishes in the heat of battle, I don't have time to manually find 3 workers that aren't holding any minerals.  What is the optimal way to transfer 3 workers from minerals to gas without sacrificing any minerals?
What's the most efficient way to transfer workers that are mining minerals to mine gas instead?
gaming.stackexchange.com
<starcraft-2>
gaming.stackexchange.com/questions/5230
gaming.stackexchange.com/users/8/Emmett
Select and 3 workers; right click on the gas and hit C. You are telling the worker to finish mining, drop off minerals and mine gas. It seems the most efficient way is to select 3 workers, right click on the gas, then clock C to return cargo, after which they will mine gas.
Users recommend dropping off minerals before mining gas.