Search code examples
google-cloud-platformcommand-line-interfacegcloud

How to change the project in GCP using CLI commands


How can I change the current running project to another project in GCP (Google Cloud Platform) account using cli commands other than using gcloud init manually?

gcloud projects list will list the projects running on my account. I want to change the current project to any other project from the list using a cli command.


Solution

  • gcloud config set project $MY_PROJECT_ID
    
    #=>
    
    Updated property [core/project].
    

    You may also set the environment variable $CLOUDSDK_CORE_PROJECT.