.

Set defaults for gcloud commands

In the Google Cloud CLI, configurations enable you to set properties that affect the behavior of the active gcloud session. A default configuration is created when you initialize Google Cloud CLI 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 Google Cloud CLI active configuration so that you don't 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. You can do this with the --repository or --location flag in your command.

If you're using repository modes other than standard mode, or frequently using repositories in different locations, setting default values might not be helpful.

Setting a default project

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

 gcloud  
config  
 set 
  
project  
 PROJECT 
 

Replace PROJECT with 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  
artifacts  
packages  
list  
--project = 
my-project 

Setting a default repository

To set a default repository, run the command:

 gcloud  
config  
 set 
  
artifacts/repository  
 REPOSITORY 
 

Replace REPOSITORY with the 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  
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 
 

Replace LOCATION with the regional or multi-regional location of the repository.

To view a list of supported locations, run the command:

 gcloud  
artifacts  
locations  
list 

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

 gcloud  
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 
Design a Mobile Site
View Site in Mobile | Classic
Share by: