COMMAND REFERENCE

Know what a command changes.

Search by command or intent—try “undo last commit”, “create branch”, or “find text”.

COMMANDPURPOSEAFFECTSRISK
git initRepository
Create an empty Git repository.git init
repository, HEAD, refs Safe
git statusInspect
Show working tree and staging area state.git status
working tree, index Safe
git addStaging
Copy file changes into the staging area.git add <path>
index, snapshot Changes index
git commitHistory
Create an immutable snapshot from staged changes.git commit -m "message"
commit, parent, tree Changes history
git switchBranches
Switch branches or create a new branch.git switch [-c] <branch>
HEAD, branch ref Changes files
git mergeBranches
Join another line of history into the current branch.git merge <branch>
fast-forward, merge commit Changes history
git resetRecovery
Move a branch reference and optionally reset index and files.git reset [--soft|--mixed|--hard] <commit>
refs, index, working tree Potentially destructive
git reflogRecovery
Inspect recent movements of HEAD.git reflog
reflog, recovery Safe
touchLinux
Create a file or update its timestamp.touch <file>
filesystem Changes files
echoLinux
Print text, often with redirection into a file.echo "text" > file
stdout, redirection Changes files
grepLinux
Filter lines that match a pattern.grep <pattern> [file]
pipes, text Safe
rmLinux
Remove files from the virtual filesystem.rm [-r] <path>
filesystem Potentially destructive