Guide to Switching gcloud Accounts and Projects VS Code
Here is a step-by-step guide to switching accounts and projects in the Google Cloud CLI (gcloud
). You can use this to quickly switch contexts for your work.
This guide assumes you have the Google Cloud SDK installed. All commands are run from your local terminal.
Step 1: Check Your Current Configuration
Before you switch, it's a good practice to see what account and project you're currently using.
-
To see the current active account and project:
gcloud config list
-
To list all accounts you have authenticated with:
gcloud auth list
Step 2: Log In to the New Account
If the account you need to use isn't in your gcloud auth list
output, you need to log in to it.
-
Run the login command. This will open a browser window and prompt you to sign in.
gcloud auth login
-
You will be asked to choose or enter the account you want to use. Choose the Google account that has permissions on the project you want to work on.
Step 3: Switch the Active Account and Project
After you have logged in to all the accounts you need, you can quickly switch between them.
-
To set the active account:
gcloud config set account <ACCOUNT_EMAIL>
Replace
<ACCOUNT_EMAIL>
with the email address of the account you want to use. You can get this fromgcloud auth list
. -
To set the active project:
gcloud config set project <PROJECT_ID>
Replace
<PROJECT_ID>
with the ID of the project you want to work on (e.g.,folosolo-2025
).
Step 4: Set Quota Project for Local Development
This is the command you learned about that solves the "quota exceeded" warning for your local environment. It's a good practice to run this after you switch projects.
-
Set the quota project:
gcloud auth application-default set-quota-project <PROJECT_ID>
Example Workflow: Switching to yourproject-2025
Let's say you're currently in a different project and need to switch to yourproject-2025
using your Google account my-email@gmail.com
.
-
Check current status:
gcloud config list
(This shows you're on
different-450212-j8
) -
Switch the project:
gcloud config set project yourproject-2025
-
Ensure correct account is active:
gcloud config set account my-email@gmail.com
-
Set the quota project for ADC:
gcloud auth application-default set-quota-project yourproject-2025
By following these steps, you can confidently switch between your projects and accounts without running into authentication errors.