"Gallery" is not a location; it is a picture viewing app.
Your pictures are first written to the phone's internal storage or SD card.
Then Google Photos will transfer them to the cloud.
If you are using a picture viewer that knows how to talk to the Google Photos servers, you can later remove the pictures from the phone while keeping them in the Google servers. I don't use the Google Photos system, so I don't know the exact way to do this.