Is it selfish to not let others copy off my work that I worked so hard on?

I suspect the reason that you are having problems getting your group to do their work is simple. They know you will pick up the slack and that they will get a great grade without having to do any work. Your willingness to help is being taken advantage off. You need to start saying no and also need to pick better group members. Until then you will be a doormat that will be walked on. Harsh but likely true.

As others mentioned, giving code to other groups would be consider a serious honor code violation. Submitting a group project that was completely done by one person sound like a gray area to me. Basically your follow group members are taking credit for work they did not contribute to and receiving credit for work they did not do.