Git Terminal Reference

Daily Git Basics

git init Start new repo

Example: Run in project root to initialize git.

git clone Copy remote repo

Example: git clone [url]

git status Check repo state

Example: See which files are modified or staged.

git add . Stage changes

Example: git add index.html

git commit Save changes

Example: git commit -m "Initial commit"

git log View history

Example: git log --oneline

Branching

git branch List branches

Example: Shows all local branches.

git branch [name] Create branch

Example: git branch feature-login

git checkout Switch branch

Example: git checkout main

git checkout -b Create + switch

Example: Short for branch + checkout.

git merge Merge branches

Example: git merge feature-branch

git rebase Clean history

Example: git rebase main

Remote & Collab

git remote -v Check remotes
git pull Fetch + merge
git push Upload commits
git fetch Download changes
git pull --rebase Clean sync
git push -u Set upstream

Undo Like a Pro

git restore Discard changes
git reset Unstage commits
git revert Safe undo commit
git stash Save work temporarily
git stash pop Restore stashed
git reset --hard Full rollback

Debugging

git blame Who broke this?
git show Inspect commit
git reflog Recover lost commits
git diff See code changes

Power Commands

git cherry-pick Pick specific commit
git clean -fd Remove junk files
Copied to clipboard! 📋