Git CLI Cheat Sheet: Config, Remotes, Stash & Tags
The Git CLI commands beyond the basics - config, remotes, stash, tags, and triage.
Setup, remotes, and the power-user commands you reach for occasionally.
Config & remotes
| Command | Does |
|---|
| git config --global user.name "X" | Set identity |
| git remote -v | List remotes |
| git remote add name url | Add a remote |
| git fetch --all --prune | Update + drop gone branches |
| git remote set-url origin url | Change remote URL |
Stash
| Command | Does |
|---|
| git stash push -m "msg" | Stash with label |
| git stash list | List stashes |
| git stash pop | Apply + drop latest |
| git stash apply stash@{1} | Apply specific |
| git stash -u | Include untracked |
Tags
| Command | Does |
|---|
| git tag v1.0.0 | Lightweight tag |
| git tag -a v1.0.0 -m "msg" | Annotated tag |
| git push origin v1.0.0 | Push one tag |
| git push --tags | Push all tags |
| git tag -d v1.0.0 | Delete local tag |
Triage
| Command | Does |
|---|
| git cherry-pick SHA | Apply a commit elsewhere |
| git bisect start / good / bad | Binary-search a regression |
| git clean -fdx | Remove untracked + ignored |
| git show SHA | Inspect a commit |
Key takeaways
- Annotated tags (-a) store a tagger and message; releases should use them.
- git bisect binary-searches commits to pinpoint a breaking change.
- fetch --prune removes local refs for branches deleted upstream.
Related guides
Git Cheat Sheet: Everyday Commands and RecoveryA Git cheat sheet - branching, committing, rebasing, stashing, undoing mistakes, and the recovery commands th…
Git Branching Cheat Sheet: Branches, Merge & RebaseA Git branching cheat sheet - create, switch, merge, rebase, delete branches, plus fast-forward vs merge comm…
Semantic Versioning Cheat Sheet: SemVer Rules & RangesA semantic versioning cheat sheet - MAJOR.MINOR.PATCH rules, prerelease and build metadata, and the npm range…