note
Prerequisite: Google Cloud SDK should be installed. See the docs here.
1
2
3
4
5
6
7
8
9
$ gcloud version
Google Cloud SDK 250.0.0
app-engine-go
app-engine-python 1.9.86
beta 2019.05.17
bq 2.0.43
cloud-datastore-emulator 2.1.0
core 2019.06.07
gsutil 4.38

gcloud project configurations are typically stored in the following folder in files with prefix config_. For example: config_my-project-name

1
2
3
$ cd ~/.config/gcloud/configurations && ls -la
-rw-r--r--   1 penkovski  staff   83 Apr 19 09:17 config_default
-rw-r--r--   1 penkovski  staff   83 Apr 19 09:17 config_my-project-name

To add a new project configuration, run the gcloud init command and follow the instructions.

1
gcloud init

After successfully selecting the desired project and options, a new config file will appear in the configurations folder. To switch the active configuration for a new project use the following command:

1
gcloud config configurations activate my-project-name

Set the currently active project:

1
2
$ gcloud config set project my-project-name
Updated property [core/project].

Get the currently active project:

1
2
3
$ gcloud config get-value project
Your active configuration is: [my-project-name]
my-project-name