How To Change The Project In GCP Using CLI Commands ?
Last Updated :
03 Jul, 2024
Google Cloud Platform(GCP) offers various Cloud services such as cloud storage, cloud computing, deploying and scaling applications in the cloud e,c. GCP offers pay-per-use services. Apart from these, GCP offers many other services like hosting your websites in the cloud, running your own Operation System from the Cloud, and other cloud computing processes.
Projects In Google Cloud Platform ( GCP )
In GCP, projects are basic units that act as containers to organize the work, resources, billings, etc. Each project has its resources, access controls, billings, etc. The cost for resources is calculated and billed separately for each project. You need to set up a project first to work with any cloud service offered by GCP. Each GCP project contains a unique PROJECT_ID and a PROJECT_NUMBER. While the PROJECT_ID is user-defined, the PROJECT_NUMBER is assigned by GCP.
GCP Console Vs CLI
GCP offers both CONSOLE and a Command Line Interface (CLI). The Console is the Graphical User Interface (GUI) to interact with the platform. You can use the Console to create a project, change the project, launch a VM etc. On the other hand, CLI is the command line tool to interact with the platform. You can use commands to create or change the project and all other tasks.
Steps To Change The Project In GCP Using CLI Commands
Step 1: Goto GCP Cloud Console
Step 2: Create a Project
Step 3: Activate Cloud Shell from the GCP Console.
- Cloud Shell is the Command Line tool provided by GCP.
- Click on the top right button as shown below to activate Cloud Shell. We need to activate the Cloud Shell to interact with GCP using CLI commands.

Step4: List all the projects
- Once the Cloud Shell is activated, list all the projects using the below command:
gcloud projects list
- The above command will list all the projects in your GCP account as shown below.
- You can see the PROJECT_ID, NAME and PROJECT_NUMBER for all the projects. Kindly note the PROJECT_ID of the project to which you need to change.

- The above image shows that I have three projects in my GCP account. They are
1. My First Project
2. GeeksforGeeks Project and
3. geekyWebsite
- In the remaining section, I will walk you through how to change the project from Website for geek to GeeksforGeeks Project.
- Kindly note the PROJECT_ID of GeeksforGeeks Project is geeksforgeeks-project1.
Step 5: Check the currently configured Project
Before changing the project, check the currently configured project using the below command
gcloud config list project
The above commands give the PROJECT_ID of the currently configured project as project = PROJECT_ID. The below image shows that I am in the project named "Website for geek" with PROJECT_ID as geekywebsite.

Step 6: Change the project using the below command
gcloud config set project PROJECT_ID
- For example, if I want to change the project from Website for geek to GeeksforGeeks Project I will use the below command
gcloud config set project geeksforgeeks-project1
- geeksforgeeks-project1 is the PROJECT_ID of GeeksforGeeks Project. You can check the ID from the previous all projects list image.
Step 7: Confirm the change
- This can be done by checking the currently configured project in our previous command
gcloud config list project
- As you can see the PROJECT_ID is now changed to geeksforgeeks-project1 from the below image.

Congratulations! You have successfully changed the project using CLI commands.
Similar Reads
How to Use 'git remote add origin' Command?
The `git remote add origin` command is used to add a remote repository to your local Git repository. This allows you to push and pull changes between your local and remote repositories. The term "origin" is an alias that refers to the remote repository URL. By convention, "origin" is used for the pr
2 min read
How To Change The Root Folder Of Your Git Repo?
Changing the root folder of your Git repository involves moving the .git directory to a new location and ensuring that your project's files are in the correct structure relative to this new root.To change the root folder of your Git repository, you essentially need to move the .git directory to the
1 min read
How to Use the Git Submodule Init and Update Command?
Git submodules allow you to include and manage external repositories within your main repository. This is particularly useful for projects that rely on libraries or other codebases that are maintained separately. The `git submodule init` and `git submodule update` commands are essential for initiali
3 min read
How To Delete Project In GCP ?
Google Cloud Platform is one of the leading Cloud service providers in the market of Cloud Computing providing various cloud services to developers and organizations. Google Cloud helps organizations to migrate to online platforms and get rid of managing physical servers for operation. Services like
7 min read
How To Create GCP Bucket Using CLI ?
Users can store and manage their data in the cloud with Google Cloud Storage (GCS), the service is provided by the Google Cloud Platform (GCP). Having the big virtual hard drive to store files, documents, photos, movies, and other media is similar to that. Within Google Cloud Storage, a bucket refer
4 min read
How to Create Storage Bucket in GCP Using Terraform?
In Cloud Computing, it is very crucial to provide efficient storage solutions. Google Cloud Platform (GCP) offers an exemplary service through it's Storage Bucket. Storage Buckets are versatile containers for securely storing data objects while providing scalability, durability, and global accessibi
6 min read
How to Create Load Balancer in GCP using Terraform ?
As traffic controls, load balancers on the Google Cloud Platform (GCP) distribute incoming requests among multiple instances of your application. Consider them as traffic engineers that direct customers to the busiest locations to deliver a dependable and responsive service, especially during period
5 min read
How To Change the Remote a Branch is Tracking in Git?
In Git, branches allow multiple developers to work on different features or fixes simultaneously. Often, a branch is set to track a remote branch, which means that Git can keep track of which commits have been pushed to or pulled from that remote branch. There might be situations where you need to c
3 min read
How To Create A GCP Project ?
Google Cloud Platform is one of the leading providers of cloud computing in the industry. GCP provides multiple services, like infrastructure as a service (IaaS), platform as a service (PaaS), and many more. Using the Google Cloud Platform, businesses can get rid of managing physical servers and ins
7 min read
Adding JGit to the Project with Maven
Integrating the JGit with Maven not only enhances the project version control capabilities but also streamlines workflow processes by leveraging the Maven build and dependency management system. This article will guide you through the steps of adding JGit to the Maven project and enabling you to har
3 min read