Setting defaults for gcloud commands

In Cloud SDK, configurations enable you to set properties that affect the behavior of the active gcloud session. A default configuration is created when you initialize Cloud SDK and you can create other named configurations.

A configuration can include default values for specific properties so that you do not need to specify them in your commands.

For more information about using configurations, see the gcloud config documentation.

Setting defaults

You can set a default project, repository, and repository location in the Cloud SDK active configuration so that you do not need to include them in commands where those values are required. If you do specify a value for a project, repository, or repository location, that value overrides the configured default.

Setting a default project

To set default project for all gcloud commands, run the command:

gcloud config set project PROJECT

Where PROJECT is the ID of the project or fully qualified identifier for the project.

To override the default, use the --project flag in your command. For example

 gcloud beta artifacts packages list --project=my-project

Setting a default repository

To set a default repository, run the command:

gcloud config set artifacts/repository REPOSITORY

Where REPOSITORY is name of the repository, or fully qualified identifier for the repository.

To override the default, use the --repository flag in your command. For example

gcloud beta artifacts packages list --repository=my-repo

Setting a default location

To set a default repository location, run the command:

gcloud config set artifacts/location LOCATION

Where LOCATION is the regional or multi-regional location for the repository. To view a list of supported locations, run the command:

gcloud beta artifacts locations list

To override the default, use the --location flag in your command. For example

gcloud beta artifacts packages list --repository=my-repo --location=us-central1

Removing default values

When you remove a default value for a configuration property, you must specify it in gcloud commands that require the property.

To unset the default project run the following command:

gcloud config unset project

To unset the default repository, run the following command:

gcloud config unset artifacts/repository

To unset the default location, run the following command:

gcloud config unset artifacts/location