Installing and Uninstalling Google Cloud CLI on MacOS Using Homebrew

Managing the Google Cloud CLI (gcloud) on your macOS system can be accomplished through two primary methods: using Homebrew or performing a manual installation. Below are concise guides for both installing and uninstalling the CLI using these methods.

Installation:

  1. Ensure Homebrew is Updated: Open Terminal and run:

    brew update
    
  2. Install Google Cloud SDK: Execute:

    brew install --cask google-cloud-sdk
    
  3. Initialize gcloud: After installation, initialize the CLI:

    gcloud init
    

Uninstallation:

  1. Uninstall the SDK: In Terminal, run:

    brew uninstall --cask google-cloud-sdk
    
  2. Remove Residual Files: To delete remaining configuration or cache files:

    rm -rf ~/.config/gcloud
    rm -rf ~/Library/Caches/google-cloud-sdk