Opens browser to authenticate your Google account with Firebase CLI.
Switch Account
firebase login:use
Switch between accounts without logging out. Useful for personal vs work projects.
List All Projects
firebase projects:list
Shows all Firebase projects linked to your current account.
Switch Active Project
firebase use
Changes which project your commands target. Run firebase use --add to create aliases like "prod" or "dev".
๐งช Development & Testing
Run All Emulators
firebase emulators:start
Starts local emulators for Functions, Firestore, Auth, etc. Test without hitting production or using quota.
Emulators + Import Data
firebase emulators:start --import=
Loads previously exported emulator data so you don't start fresh each time.
Watch Cloud Function Logs
firebase functions:log --only
Streams real-time logs from deployed functions. Leave function name blank to see all.
Serve Hosting Locally
firebase serve --only hosting
Preview your static site locally before deploying. Faster than full emulators if you only need hosting.
๐ Granular Deployment
Deploy Everything
firebase deploy
Deploys all configured services (Hosting, Functions, Rules, etc.) at once.
Deploy Hosting Only
firebase deploy --only hosting
Just pushes static files. Much faster when you haven't touched functions.
Deploy All Functions
firebase deploy --only functions
Redeploys all Cloud Functions. Can take a few minutes if you have many.
Deploy ONE Function
firebase deploy --only functions:
Deploy a single function by name. Way faster when iterating on one function.
Deploy Firestore Rules
firebase deploy --only firestore:rules
Updates security rules without touching anything else. Takes effect immediately.
๐ Setup & Init
Initialize New Project
firebase init
Interactive wizard to set up Hosting, Functions, Firestore, etc. Creates config files in your directory.
Add Project Alias
firebase use --add
Creates shortcuts like "prod" or "staging" so you can quickly switch with firebase use prod.
Check Current Project
firebase use
Shows which project is currently active. Always check before deploying!
2. Git Fundamentals
โฌ๏ธ Getting Code (Pull/Clone)
Clone Repo (First Time)
git clone
Downloads a repo for the first time. Creates a folder with all files and history.
Pull Latest Changes
git pull origin
Fetches and merges remote changes into your local branch. Do this before starting work.
Fetch Without Merging
git fetch origin
Downloads remote changes but doesn't apply them. Useful to see what's new before merging.
โฌ๏ธ Saving Code (Push)
Check Status
git status
Shows modified, staged, and untracked files. Run this often to see where you're at.
Stage All + Commit
git add . && git commit -m ""
Stages all changes and creates a commit. Write a short, meaningful message.
Push to GitHub
git push origin
Uploads your commits to GitHub. Now other machines can pull your changes.
View Commit History
git log --oneline -10
Shows last 10 commits in compact format. Great for finding commit hashes.
๐ฟ Branches
List All Branches
git branch -a
Shows local and remote branches. Current branch marked with asterisk.
Create & Switch to Branch
git checkout -b
Creates a new branch from current position and switches to it immediately.
Switch Branch
git checkout
Switches to an existing branch. Commit or stash changes first!
Merge Branch Into Current
git merge
Brings changes from another branch into your current branch. May need conflict resolution.
๐ฆ Stash (Temporary Storage)
Stash Current Changes
git stash
Temporarily shelves uncommitted changes. Lets you switch branches with a clean slate.
Stash With Name
git stash push -m ""
Stash with a description so you remember what it was for later.
List Stashes
git stash list
Shows all stashed changes with their index numbers and messages.
Apply & Remove Latest Stash
git stash pop
Restores most recent stash and removes it from the stash list.
โ ๏ธ Undo & Recovery
Discard ALL Local Changes
git checkout -- .
Wipes all uncommitted changes permanently. Cannot be undone!
Undo Last Commit (Keep Files)
git reset --soft HEAD~1
Removes the last commit but keeps all changes staged. Good for fixing commit messages.
Hard Reset to Remote
git reset --hard origin/
Nuclear option: makes your local branch identical to remote. All local changes lost forever.
Unstage Files (Keep Changes)
git reset HEAD
Removes files from staging area but keeps your edits intact. Opposite of git add.
๐ง Config & Remote
Set Username
git config --global user.name ""
Sets the name attached to your commits. Required for first-time Git setup.
Set Email
git config --global user.email ""
Sets email for commits. Use your GitHub email to link commits to your profile.
View Remotes
git remote -v
Shows URLs for fetch and push. Useful to verify which GitHub repo you're connected to.
3. NPM & Node.js
๐ฆ Package Management
Install All Dependencies
npm install
Reads package.json and installs everything. Run this after cloning a repo.
Install Specific Package
npm install
Adds a package to your project and saves it to package.json dependencies.
Install as Dev Dependency
npm install -D
For packages only needed during development (testing, building). Not included in production.
Uninstall Package
npm uninstall
Removes a package from node_modules and package.json.
๐ Updates & Security
Check for Outdated
npm outdated
Lists packages with newer versions available. Shows current vs wanted vs latest.
Update All Packages
npm update
Updates packages to latest versions within the ranges specified in package.json.
Security Audit
npm audit
Scans dependencies for known vulnerabilities. Shows severity levels and fix suggestions.
Auto-Fix Vulnerabilities
npm audit fix
Automatically updates vulnerable packages to patched versions when possible.
โถ๏ธ Scripts & Running
Run Start Script
npm start
Runs the "start" script from package.json. Usually launches the dev server.
Run Custom Script
npm run
Runs any script defined in package.json. Common ones: build, test, dev, lint.
Run with npx (No Install)
npx
Runs a package without permanently installing it. Great for one-time CLI tools.
List Available Scripts
npm run
Shows all available scripts defined in package.json. Useful in unfamiliar projects.
๐งน Cleanup & Cache
Clear NPM Cache
npm cache clean --force
Clears the npm cache. Try this when installs are behaving strangely.
Delete node_modules
rm -rf node_modules
Removes all installed packages. Usually followed by a fresh npm install.
Fresh Install
rm -rf node_modules && npm install
Nuclear option: wipes and reinstalls everything. Fixes most "weird dependency" issues.
4. Docker & Google Cloud
๐ณ Docker Basics
Build Image
docker build -t.
Creates an image from your Dockerfile. The dot means "use current directory".
Run Container
docker run -p 8080:8080
Starts a container from an image. -p maps container port to your machine's port.
List Running Containers
docker ps
Shows all running containers with their IDs, ports, and names.
Stop Container
docker stop
Gracefully stops a running container. Get the ID from docker ps.
โ๏ธ Google Cloud Run
Login to GCloud
gcloud auth login
Opens browser to authenticate your Google account with the gcloud CLI.
Set Project
gcloud config set project
Sets which GCP project commands will target. Find your project ID in the console.
Deploy to Cloud Run
gcloud run deploy
Interactive deploy that prompts for service name, region, and settings. Builds and deploys in one step.
Build & Push to GCR
gcloud builds submit --tag gcr.io/
Builds your Docker image in the cloud and pushes to Google Container Registry.
๐ Cloud Run Management
List Services
gcloud run services list
Shows all your Cloud Run services with their URLs and regions.
View Logs
gcloud run services logs read
Streams logs from a deployed service. Essential for debugging production issues.
Delete Service
gcloud run services delete
Permanently removes a Cloud Run service. Will prompt for confirmation.
5. Terminal Power Tools
๐ Finding Things
Find Process on Port
lsof -i :
Shows which process is using a port. Fixes "Address already in use" errors.
Kill Process by PID
kill -9
Force-kills a process by its ID. Get the PID from lsof or ps aux.
Search Command History
history | grep
Finds past commands containing a keyword. Great for remembering complex commands.
Find Files by Name
find . -name "**"
Recursively searches for files matching a pattern. The dot means "start from here".
๐ File Operations
Copy Directory
cp -r
Copies a folder and all its contents recursively. -r means "recursive".
Disk Usage (Folder Size)
du -sh */
Shows size of each folder in current directory. -h makes it human-readable (MB, GB).
Watch File Changes
tail -f
Live-streams new lines as they're added to a file. Perfect for watching logs.
๐ Network & Curl
Test URL Response
curl -I
Fetches only HTTP headers. Quick way to check if a URL is responding.
POST JSON
curl -X POST -H "Content-Type: application/json" -d '{}' URL
Sends a POST request with JSON body. Replace {} with your data and URL at the end.
Check Local IP
ipconfig getifaddr en0
Shows your local network IP (macOS). On Linux use hostname -I instead.
๐ก Pro Tip: Use Ctrl+R in terminal to reverse-search your command history.
Press Tab to autocomplete paths and commands. Chain commands with && (runs next only if previous succeeds).