Git Cheat Sheet With Inline Info
# Initialize & Clone
git init # Create a new repository in current folder
git clone <url> # Copy a remote repo locally
# Status & Commit
git status # Show repo state (staged/unstaged files)
git add . # Stage all changes
git commit -m "msg" # Save snapshot with message
git log --oneline # Compact commit history
git diff # Show changes not staged/committed
# Branching
git branch # List branches
git branch <name> # Create new branch
git checkout <name> # Switch branch
git checkout -b <name> # Create + switch branch
git merge <branch> # Merge branch into current
git rebase <branch> # Reapply commits on top of branch
# Remote
git remote -v # Show remotes
git remote add origin <url> # Add remote repo
git push origin main # Push changes to remote main
git pull origin main # Fetch + merge from remote main
git fetch origin # Fetch without merging
# Undo & Reset
git reset <file> # Unstage file
git checkout -- <file> # Discard local changes
git revert <commit> # Undo commit safely (new commit)
git reset --hard <commit> # Reset repo to commit (dangerous)
# Stash
git stash # Save changes temporarily
git stash list # Show stashes
git stash apply # Reapply latest stash
git stash drop # Delete latest stash