Git CLI Skill — How to Work
Use this skill when the user asks about Git from the command line: what changed, staging/committing, branching, push/pull, stashing, history, tags, merge/rebase, or cloning.
Your Workflow
- Confirm context: Ensure Git is on PATH and the user is in (or will run commands in) a repo. If unsure, suggest
git status or run scripts/is-repo.sh from the skill directory.
- Safety first: Prefer read-only commands (
git status, git diff, git log). Do not suggest destructive commands (git reset --hard, git clean -fdx, git push --force) unless the user explicitly asks and understands the risk. For recovery, use git reflog to find a commit before suggesting reset/checkout.
- Give the right level of detail:
- Quick answer: Use the Quick Reference table below and reply with the exact command(s).
- Step-by-step or edge cases: Point to or quote from reference/ (e.g. reference/workflows.md, reference/troubleshooting.md).
- Automation / repeatable checks: Use or adapt scripts in scripts/ and tell the user how to run them.
- Templates (commit message, .gitignore): Use or copy from assets/.
Quick Reference (use this first)
| Task |
Command |
| State & diff |
git status · git diff · git diff --staged · git diff --stat |
| Stage / unstage |
git add <path> or git add . · git restore --staged <path> |
| Commit |
git commit -m "message" |
| Branch |
git branch · git branch -a · git switch -c new · git switch existing |
| Sync remote |
git fetch · git pull · git push -u origin <branch> then git push |
| Stash |
git stash · git stash list · git stash apply / git stash pop |
| History |
git log --oneline --decorate --graph -n 20 · git blame <file> |
| Clone / init |
git clone <url> · git init · git remote add origin <url> |
| Remotes |
git remote -v · git remote show origin · git branch -vv |
| Discard (destructive) |
git restore <file> (working tree) · git restore --staged <file> (unstage) |
| Amend |
git commit --amend --no-edit or -m "message" |
| Tags |
git tag · git tag v1.0 · git push origin v1.0 or --tags |
| Merge / rebase |
git merge <branch> · git rebase <branch> · conflict → fix → git add → git commit or git rebase --continue |
Where to Look
| Need |
Location |
| Full command list, options, examples |
reference/commands.md |
| Step-by-step workflows (branch, release, conflict) |
reference/workflows.md |
| Errors, recovery, detached HEAD, .gitignore |
reference/troubleshooting.md |
| Run checks (is repo, status summary, branch info) |
scripts/ — run from repo root |
| Commit message or .gitignore template |
assets/ |
Scripts (run from repository root)
- scripts/is-repo.sh — Exit 0 if current dir is a Git repo, else 1. Use to confirm context before suggesting commands.
- scripts/status-summary.sh — Short status + branch + last commit. Use when user asks "what’s my current state?"
- scripts/branch-list.sh — Local and remote branches with upstream. Use when user asks about branches or push target.
On Windows: run in Git Bash or WSL (e.g. bash scripts/status-summary.sh).
Assets
- assets/commit-msg-template.txt — Template for conventional or structured commit messages; suggest when user asks for commit message format.
- assets/gitignore-common.txt — Common .gitignore patterns; suggest when user has many untracked files or asks for .gitignore examples.
When the user needs a diagram (e.g. branch/merge flow), describe it in text or point to reference; only create or reference images in assets/ if the user explicitly asks for a visual.
1---2name: git-cli3description: Guides Git CLI operations from the command line, covering status checks, diffs, staging, commits, branching, stashing, and syncing with remotes, with a safety-first approach and reference materials.4---5
6# Git CLI Skill — How to Work
7
8Use this skill when the user asks about **Git from the command line**: what changed, staging/committing, branching, push/pull, stashing, history, tags, merge/rebase, or cloning.
9
10## Your Workflow
11
121. **Confirm context**: Ensure Git is on PATH and the user is in (or will run commands in) a repo. If unsure, suggest `git status` or run `scripts/is-repo.sh` from the skill directory.
132. **Safety first**: Prefer read-only commands (`git status`, `git diff`, `git log`). Do not suggest destructive commands (`git reset --hard`, `git clean -fdx`, `git push --force`) unless the user explicitly asks and understands the risk. For recovery, use `git reflog` to find a commit before suggesting reset/checkout.
143. **Give the right level of detail**:
15 - **Quick answer**: Use the Quick Reference table below and reply with the exact command(s).
16 - **Step-by-step or edge cases**: Point to or quote from [reference/](reference/) (e.g. [reference/workflows.md](reference/workflows.md), [reference/troubleshooting.md](reference/troubleshooting.md)).
17 - **Automation / repeatable checks**: Use or adapt scripts in [scripts/](scripts/) and tell the user how to run them.
18 - **Templates** (commit message, .gitignore): Use or copy from [assets/](assets/).
19
20## Quick Reference (use this first)
21
22| Task | Command |
23|------|--------|
24| State & diff | `git status` · `git diff` · `git diff --staged` · `git diff --stat` |
25| Stage / unstage | `git add <path>` or `git add .` · `git restore --staged <path>` |
26| Commit | `git commit -m "message"` |
27| Branch | `git branch` · `git branch -a` · `git switch -c new` · `git switch existing` |
28| Sync remote | `git fetch` · `git pull` · `git push -u origin <branch>` then `git push` |
29| Stash | `git stash` · `git stash list` · `git stash apply` / `git stash pop` |
30| History | `git log --oneline --decorate --graph -n 20` · `git blame <file>` |
31| Clone / init | `git clone <url>` · `git init` · `git remote add origin <url>` |
32| Remotes | `git remote -v` · `git remote show origin` · `git branch -vv` |
33| Discard (destructive) | `git restore <file>` (working tree) · `git restore --staged <file>` (unstage) |
34| Amend | `git commit --amend --no-edit` or `-m "message"` |
35| Tags | `git tag` · `git tag v1.0` · `git push origin v1.0` or `--tags` |
36| Merge / rebase | `git merge <branch>` · `git rebase <branch>` · conflict → fix → `git add` → `git commit` or `git rebase --continue` |
37
38## Where to Look
39
40| Need | Location |
41|------|----------|
42| Full command list, options, examples | [reference/commands.md](reference/commands.md) |
43| Step-by-step workflows (branch, release, conflict) | [reference/workflows.md](reference/workflows.md) |
44| Errors, recovery, detached HEAD, .gitignore | [reference/troubleshooting.md](reference/troubleshooting.md) |
45| Run checks (is repo, status summary, branch info) | [scripts/](scripts/) — run from repo root |
46| Commit message or .gitignore template | [assets/](assets/) |
47
48## Scripts (run from repository root)
49
50- **scripts/is-repo.sh** — Exit 0 if current dir is a Git repo, else 1. Use to confirm context before suggesting commands.
51- **scripts/status-summary.sh** — Short status + branch + last commit. Use when user asks "what’s my current state?"
52- **scripts/branch-list.sh** — Local and remote branches with upstream. Use when user asks about branches or push target.
53
54On Windows: run in Git Bash or WSL (e.g. `bash scripts/status-summary.sh`).
55
56## Assets
57
58- **assets/commit-msg-template.txt** — Template for conventional or structured commit messages; suggest when user asks for commit message format.
59- **assets/gitignore-common.txt** — Common .gitignore patterns; suggest when user has many untracked files or asks for .gitignore examples.
60
61When the user needs a diagram (e.g. branch/merge flow), describe it in text or point to reference; only create or reference images in assets/ if the user explicitly asks for a visual.