Skip to content
Latchkey

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

CommandDoes
git config --global user.name "X"Set identity
git remote -vList remotes
git remote add name urlAdd a remote
git fetch --all --pruneUpdate + drop gone branches
git remote set-url origin urlChange remote URL

Stash

CommandDoes
git stash push -m "msg"Stash with label
git stash listList stashes
git stash popApply + drop latest
git stash apply stash@{1}Apply specific
git stash -uInclude untracked

Tags

CommandDoes
git tag v1.0.0Lightweight tag
git tag -a v1.0.0 -m "msg"Annotated tag
git push origin v1.0.0Push one tag
git push --tagsPush all tags
git tag -d v1.0.0Delete local tag

Triage

CommandDoes
git cherry-pick SHAApply a commit elsewhere
git bisect start / good / badBinary-search a regression
git clean -fdxRemove untracked + ignored
git show SHAInspect 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →