Unless you know someone who can wrangle the unlock code from Tmobile, you may have to pay for it, but it is possible, if your carrier uses a sim card. Try calling Tmobile, they may give it to you, or if you know someone who has Tmobile, ask them to call and ask for it. (they send it via email so it takes a few days). You can also buy it from several places online.
The G-1 has to have another carrier's sim in to unlock, so just put in your sim and enter the code when you get it. Depend on your carrier, you may have to tell them that you changed phones, or you may not. You will need your carrier's APN settings (most can be found online) to get online with it. You may also need to do some fancy stuff to get logged in, or you may not.
If you don't have a sim, then the answer is no.