Quick reference guides for common developer tools and languages. Click any command to copy.
git config --global user.name "Name"
Set global username
git config --global user.email "email"
Set global email
git init
Initialize a new repo
git clone <url>
Clone a remote repo
git status
Show working tree status
git add .
Stage all changes
git commit -m "message"
Commit staged changes
git push origin main
Push to remote
git pull
Fetch and merge from remote
git branch
List branches
git branch <name>
Create a branch
git checkout <name>
Switch to branch
git switch -c <name>
Create and switch to branch
git merge <branch>
Merge branch into current
git branch -d <name>
Delete branch
git revert <commit>
Revert a commit (safe)
git reset --hard HEAD~1
Undo last commit (destructive)
git stash
Stash uncommitted changes
git stash pop
Re-apply stashed changes
git cherry-pick <commit>
Apply a specific commit
docker pull <image>
Pull an image from registry
docker build -t <name> .
Build image from Dockerfile
docker images
List local images
docker rmi <image>
Remove an image
docker run -d -p 8080:80 <image>
Run container in background
docker ps
List running containers
docker ps -a
List all containers
docker stop <id>
Stop a container
docker rm <id>
Remove a container
docker exec -it <id> bash
Shell into container
docker compose up -d
Start services in background
docker compose down
Stop and remove services
docker compose logs -f
Follow service logs
docker compose build
Build/rebuild services
ls -la
List files with details
cd <dir>
Change directory
cp -r <src> <dst>
Copy files/dirs recursively
mv <src> <dst>
Move or rename files
rm -rf <dir>
Remove directory recursively
mkdir -p <dir>
Create directories recursively
find . -name "*.js"
Find files by pattern
grep -r "pattern" .
Search text recursively
cat <file>
Print file contents
tail -f <file>
Follow file output
sed -i "s/old/new/g" <file>
Find and replace in file
awk '{print $1}' <file>
Print first column
ps aux | grep <name>
Find a process
kill -9 <pid>
Kill a process
curl -X GET <url>
Make an HTTP GET request
netstat -tulpn
Show open ports
ssh user@host
SSH into a server
arr.map(x => x * 2)
Transform each element
arr.filter(x => x > 0)
Keep matching elements
arr.reduce((acc, x) => acc + x, 0)
Accumulate values
arr.find(x => x.id === 1)
Find first match
arr.some(x => x > 5)
Check if any match
arr.flat(Infinity)
Flatten nested arrays
await fetch(url).then(r => r.json())
Fetch JSON from URL
Promise.all([p1, p2])
Run promises in parallel
Promise.allSettled([p1, p2])
All results including failures
setTimeout(() => {}, ms)
Delay execution
npm init -y
Init project with defaults
npm install <pkg>
Install a package
npm install -D <pkg>
Install as dev dependency
npm run <script>
Run a package script
npm audit fix
Fix security vulnerabilities
python3 -m venv venv
Create virtual environment
source venv/bin/activate
Activate virtual environment
pip install <package>
pip freeze > requirements.txt
Export dependencies
python3 -m http.server 8000
Serve current directory
[x*2 for x in lst]
Transform list
[x for x in lst if x > 0]
Filter list
{k: v for k, v in d.items()}
Dict comprehension
{x for x in lst}
Set comprehension
with open('file.txt') as f: data = f.read()
Read a file
with open('file.txt', 'w') as f: f.write(s)
Write to a file
import json; json.loads(s)
Parse JSON string
import json; json.dumps(obj)
Serialize to JSON
SELECT * FROM table WHERE col = val;
Basic select with filter
SELECT col, COUNT(*) FROM t GROUP BY col;
Group and count
SELECT * FROM a JOIN b ON a.id = b.aid;
Inner join
SELECT * FROM t ORDER BY col DESC LIMIT 10;
Order and limit
INSERT INTO t (col1, col2) VALUES (v1, v2);
Insert row
UPDATE t SET col = val WHERE id = 1;
Update rows
DELETE FROM t WHERE id = 1;
Delete rows
CREATE TABLE t (id SERIAL PRIMARY KEY, name TEXT);
Create table
ALTER TABLE t ADD COLUMN col TEXT;
Add column
DROP TABLE t;
Drop table
CREATE INDEX idx ON t (col);
Create index