Config, everyday workflow, branching, undo, remotes and recovery tactics for single-developer and team use. All rows are plain text - search to filter, click Copy to grab the pattern.
Reference rack
STATUSREADY
ROWS44
NETWORKLOCAL
MODEREFERENCE
| Item / pattern | What it means / how to use it | |
|---|---|---|
| git init | Create an empty repository in the current folder. | |
| git clone <url> | Copy a remote repository to your machine with full history. | |
| git config --global user.name "X" | + user.email - the identity stamped on your commits. | |
| git config --global core.editor "code --wait" | Default commit/tag message editor. | |
| git config --global init.defaultBranch main | Set main as the default branch name for new repositories. | |
| git status | State of the working tree: staged, unstaged, untracked. | |
| git add <file> / git add . | Stage one file / everything changed. | |
| git commit -m "message" | Snapshot the staged changes. | |
| git commit -am "message" | Stage tracked modifications and commit in one step. | |
| git log --oneline --graph | Concise history with the branch graph. | |
| git diff / git diff --staged | Working tree vs index / index vs last commit. | |
| git show <commit> | Full diff and metadata of a single commit. | |
| git rm <file> | Remove a file and stage the deletion. | |
| git mv <old> <new> | Rename a file and stage it. | |
| git branch <name> | Create a branch. | |
| git branch -a | List local and remote branches. | |
| git checkout <branch> / git switch <branch> | Move to another branch. | |
| git checkout -b <name> / git switch -c <name> | Create a branch and switch to it in one step. | |
| git merge <branch> | Fold the named branch into the current branch. | |
| git rebase <branch> | Re-apply your commits on top of another branch for a linear history. | |
| git branch -d <name> | Delete a merged branch; -D force-deletes an unmerged one. | |
| git push origin <branch> | Upload the branch and set the upstream at once. | |
| git restore <file> | Discard working-tree changes to that file. | |
| git restore --staged <file> | Unstage a file while keeping your edits. | |
| git reset --soft HEAD~1 | Undo the last commit but keep the changes staged. | |
| git reset --hard <sha> | Discard everything back to a commit - destructive, think twice. | |
| git revert <sha> | A new commit that reverses an old one; safe on shared history. | |
| git stash / git stash pop | Park work in progress aside, then bring it back. | |
| git clean -fd | Delete untracked files and directories - destructive. | |
| git remote -v | List remotes and their fetch/push URLs. | |
| git remote add origin <url> | Attach a remote named origin. | |
| git fetch <remote> | Download remote refs without touching your working tree. | |
| git pull / git pull --rebase | Fetch then merge / fetch then replay your commits on top. | |
| git push -u origin <branch> | Push and record the upstream tracking for future pulls. | |
| git tag <name> / git tag -a -m "msg" | Create lightweight / annotated (release-worthy) tags. | |
| git log --oneline --author=X --since=2.weeks | History filtered by author and time. | |
| git blame <file> | Who changed which line last - per-line attribution. | |
| git grep <pattern> | Search the contents of tracked files, not just filenames. | |
| git diff HEAD~1 HEAD | The delta between two commits. | |
| git reflog | The local log of every HEAD move - the way to resurrect "lost" commits. | |
| git bisect start | Then mark bad/good commits to binary-search the change that broke behavior. | |
| git worktree add <path> <branch> | Check out a branch in a separate folder for parallel work. | |
| git archive --format=zip -o src.zip HEAD | Export a clean zip of one commit; no .git history. | |
| .gitignore | Patterns of files to keep untracked - node_modules/, .env, build outputs. |