
Git Cli
- 8 installs
- 33 repo stars
- Updated April 26, 2026
- bighardperson/computer-science-skills-collection
git-cli is a skill that helps run Git command-line operations safely, covering status, staging, commits, branches, syncing, and history.
About
git-cli is a reference skill for using the Git command line to inspect, stage, commit, branch, and synchronize changes. A developer uses it to get exact Git commands for a task and to follow safe workflows that avoid destructive operations unless explicitly requested. It bundles reference docs, helper scripts, and commit and gitignore templates.
- Quick-reference table of Git commands for status, staging, branching, and syncing
- Safety-first: prefers read-only commands and gates destructive ones
- Bundled scripts to confirm repo context and summarize status
Git Cli by the numbers
- 8 all-time installs (skills.sh)
- Ranked #443 of 735 Git & Pull Requests skills by installs in the Skillselion catalog
- Data as of Jul 30, 2026 (Skillselion catalog sync)
git-cli capabilities & compatibility
Free; only requires Git on PATH
- Capabilities
- git workflow · commit help
- Works with
- github
- Use cases
- documentation
- Platforms
- macOS · Linux · Windows · WSL
- Pricing
- Free
What git-cli says it does
Helper for using the Git CLI to inspect, stage, commit, branch, and synchronize code changes.
Prefer read-only commands (`git status`, `git diff`, `git log`). Do not suggest destructive commands
On Windows: run in Git Bash or WSL (e.g. `bash scripts/status-summary.sh`).
npx skills add https://github.com/bighardperson/computer-science-skills-collection --skill git-cliAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 8 |
|---|---|
| repo stars | ★ 33 |
| Last updated | April 26, 2026 |
| Repository | bighardperson/computer-science-skills-collection ↗ |
What it does
Get the exact safe Git CLI commands for status, staging, branching, syncing, and history tasks.
Who is it for?
Getting the right safe Git CLI command for a specific task.
Skip if: GitHub-API operations like creating repos or releases.
When should I use this skill?
A user asks how to do a Git operation from the command line.
What you get
The user gets the correct Git command and a safe workflow for their task.
- Exact Git commands
- Status summary via scripts
By the numbers
- 3 bundled shell scripts (is-repo, status-summary, branch-list)
Files
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
1. 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. 2. 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. 3. 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.
{
"ownerId": "kn7fpcza5mcp31by72fennhy9h81yf28",
"slug": "git-cli",
"version": "1.0.1",
"publishedAt": 1773629679251
}{
"version": 1,
"registry": "https://clawhub.ai",
"slug": "git-cli",
"installedVersion": "1.0.1",
"installedAt": 1776071106965
}
# Commit message template (Conventional Commits style)
# Use when user asks for commit message format or examples.
# Copy the line that fits; replace scope and description.
<type>(<scope>): <short description>
[optional body - wrap at 72 chars]
[optional footer: Breaking-Change:, Fixes #123]
# Types: feat, fix, docs, style, refactor, perf, test, chore, build, ci
# Examples:
# feat(auth): add login with JWT
# fix(api): handle null in response
# docs(readme): update install steps
# chore(deps): upgrade lodash to 4.17.21
# Common .gitignore patterns
# Suggest when user has many untracked files or asks for .gitignore examples.
# Copy needed lines into project .gitignore.
# OS
.DS_Store
Thumbs.db
# Editors / IDEs
.idea/
.vscode/
*.swp
*.swo
*~
# Build / dependencies
node_modules/
dist/
build/
out/
*.pyc
__pycache__/
.venv/
venv/
env/
*.egg-info/
.eggs/
# Logs and temp
*.log
*.tmp
.cache/
# Env and secrets (do not commit real secrets)
.env
.env.local
*.pem
# Coverage / test
coverage/
.nyc_output/
.htmlcov/
.pytest_cache/
# Misc
*.bak
*.orig
Git CLI Assets
Templates and static resources for Git workflows.
| File | Use |
|---|---|
commit-msg-template.txt | Conventional Commits style; suggest when user asks for commit message format. |
gitignore-common.txt | Common .gitignore patterns; suggest when many untracked files or user asks for .gitignore. |
For diagrams or images, add to this folder and reference from SKILL.md or reference docs when the user explicitly asks for a visual.
git-cli Skill
Git 命令行助手:在 Cursor 里回答或执行与 Git 相关的操作(查看状态、暂存提交、分支、推送拉取、stash、历史、标签、合并/变基、克隆等)。SKILL.md 面向 AI,说明何时用、如何用、安全原则和快速参考;本 README 面向人类,说明目录与用法。
何时会用到
- 用户问「怎么用 Git 做 XXX」「这条命令什么意思」「push 被拒绝了怎么办」等。
- 用户需要查看当前状态、写提交信息、建分支、解决冲突、恢复误操作时,AI 会优先查本 skill 的 Quick Reference 和 reference/,必要时引用 scripts/ 或 assets/。
目录结构
git-cli/
├── SKILL.md # AI 工作指南:流程、安全、快速参考、去哪查
├── README.md # 本文件(人类可读说明)
├── reference/ # 详细参考(命令、工作流、排错)
│ ├── README.md
│ ├── commands.md # 命令列表与常用选项
│ ├── workflows.md # 分步工作流
│ └── troubleshooting.md # 常见错误与处理
├── scripts/ # 可执行脚本(需在仓库根目录运行)
│ ├── README.md
│ ├── is-repo.sh # 当前目录是否 Git 仓库
│ ├── status-summary.sh # 分支 + 上游 + 最近提交 + 状态
│ └── branch-list.sh # 本地/远程分支及上游
└── assets/ # 模板与静态资源
├── README.md
├── commit-msg-template.txt # 提交信息模板(Conventional Commits)
└── gitignore-common.txt # 常用 .gitignore 片段各目录说明
| 目录 | 内容 | 典型用法 |
|---|---|---|
| reference/ | 命令表、分步工作流、排错说明 | 需要详细步骤或查某条命令时看 commands.md、workflows.md、troubleshooting.md |
| scripts/ | Bash 脚本 | 在仓库根目录执行,如:bash path/to/scripts/status-summary.sh;Windows 上可用 Git Bash 或 WSL |
| assets/ | 提交信息与 .gitignore 模板 | 需要格式示例或忽略规则时参考 commit-msg-template.txt、gitignore-common.txt |
运行脚本
- 环境:需要已安装 Git,且当前在要检查的仓库根目录(或先
cd到该目录)。 - Windows:在 Git Bash 或 WSL 中运行,例如:
bash .cursor/skills/git-cli/scripts/status-summary.sh- 各脚本用途见 scripts/README.md。
依赖与约定
- Git:需在 PATH 中(
git --version可用)。 - 脚本:仅提供
.sh版本,便于跨平台与 clawhub 发布;Windows 用户通过 Git Bash/WSL 使用。
Git Commands Reference
Detailed command list with common options. Use when the user needs options, variants, or examples beyond the Quick Reference in SKILL.md.
Inspect state
| Command | Description |
|---|---|
git status | Short status (branch, staged, unstaged, untracked) |
git status -sb | Short + branch in one line |
git diff | Unstaged changes (working tree vs index) |
git diff --staged | Staged changes (index vs HEAD) |
git diff --stat | Summary of changed files and line counts |
git diff <commit> -- <path> | Diff working tree against a commit |
git diff A..B | Diff between two commits |
Stage and unstage
| Command | Description |
|---|---|
git add <path> | Stage file or directory |
git add . | Stage all changes in current tree |
git add -p | Interactive stage (hunk by hunk) |
git restore --staged <path> | Unstage, keep working tree changes |
git restore <path> | Discard working tree changes (destructive) |
git restore . | Discard all working tree changes (destructive) |
Commit
| Command | Description |
|---|---|
git commit -m "message" | Commit with one-line message |
git commit | Open editor for message (multi-line) |
git commit --amend --no-edit | Amend last commit, keep message, add staged files |
git commit --amend -m "message" | Amend last commit with new message |
git commit --allow-empty -m "message" | Create empty commit |
Branching
| Command | Description |
|---|---|
git branch | List local branches |
git branch -a | List local + remote-tracking |
git branch -vv | List with upstream and last commit |
git switch -c <name> | Create branch and switch (Git 2.23+) |
git switch <name> | Switch to existing branch |
git checkout -b <name> | Create and switch (classic) |
git checkout <name> | Switch (classic) |
git branch -d <name> | Delete merged branch |
git branch -D <name> | Force delete branch |
Remote and sync
| Command | Description |
|---|---|
git remote -v | List remotes and URLs |
git remote show origin | Detailed origin info (branches, push/pull) |
git fetch | Fetch from default remote |
git fetch origin | Fetch from origin |
git fetch --prune | Fetch and remove stale remote-tracking refs |
git pull | Fetch + merge current branch |
git pull --rebase | Fetch + rebase current branch |
git push -u origin <branch> | Push and set upstream |
git push | Push to upstream |
git push origin --delete <branch> | Delete remote branch |
Stash
| Command | Description |
|---|---|
git stash | Stash working tree + index |
git stash push -m "message" | Stash with message |
git stash list | List stashes |
git stash show -p stash@{0} | Show stash diff |
git stash apply | Apply top stash, keep it |
git stash pop | Apply top stash and drop |
git stash drop stash@{0} | Drop a stash |
git stash branch <name> | Create branch from stash and drop |
History and blame
| Command | Description |
|---|---|
git log --oneline -n 20 | Last 20 commits, one line each |
git log --oneline --decorate --graph --all | Graph of all branches |
git log -p -- <path> | Log with patch for file |
git log --follow -- <path> | Follow renames |
git blame <path> | Who changed each line |
git blame -L 10,20 <path> | Blame lines 10–20 |
git reflog | History of HEAD movements (for recovery) |
Tags
| Command | Description |
|---|---|
git tag | List tags |
git tag v1.0 | Lightweight tag at current commit |
git tag -a v1.0 -m "msg" | Annotated tag |
git push origin v1.0 | Push one tag |
git push origin --tags | Push all tags |
git tag -d v1.0 | Delete local tag |
git push origin --delete v1.0 | Delete remote tag |
Merge and rebase
| Command | Description |
|---|---|
git merge <branch> | Merge branch into current |
git merge --abort | Abort merge after conflict |
git rebase <branch> | Rebase current onto branch |
git rebase --continue | After resolving conflict |
git rebase --abort | Abort rebase |
git rebase -i HEAD~n | Interactive rebase last n commits |
Clone and init
| Command | Description |
|---|---|
git clone <url> | Clone into directory named from URL |
git clone <url> <dir> | Clone into <dir> |
git clone --depth 1 <url> | Shallow clone (single commit) |
git init | Create repo in current directory |
git remote add origin <url> | Add remote named origin |
Utility
| Command | Description |
|---|---|
git rev-parse --is-inside-work-tree | Print "true" or "false" (for scripts) |
git rev-parse --show-toplevel | Print repo root path |
git config --list --local | List local config |
Git CLI Reference
Detailed documentation for the git-cli skill. Use when the user needs more than the Quick Reference in SKILL.md.
| File | Content |
|---|---|
| commands.md | Full command list with options (diff, branch, remote, stash, log, tags, merge/rebase, etc.). |
| workflows.md | Step-by-step workflows: daily commit, feature branch, sync, conflicts, stash, amend, release, recovery. |
| troubleshooting.md | Common errors and fixes: not a repo, push rejected, conflicts, detached HEAD, reflog recovery, upstream, large files. |
Git Troubleshooting
Common errors and fixes. Use when the user reports an error message or unexpected behavior.
"not a git repository" / "fatal: not a git repository"
- Cause: Current directory is not inside a Git repo.
- Fix:
- Run commands from the project root (where
.gitexists), or - Initialize:
git init(new repo), or - Clone:
git clone <url>.
"Permission denied (publickey)" or auth errors on push/pull
- Cause: SSH key not set up or not added to Git host (GitHub, GitLab, etc.).
- Fix: User must configure SSH keys or use HTTPS with credentials. Point to host’s docs (e.g. "Adding SSH key to GitHub"). Do not store passwords in skill.
Push rejected: "Updates were rejected" / "non-fast-forward"
- Cause: Remote has commits the local branch doesn’t have.
- Fix:
1. git pull or git pull --rebase. 2. Resolve conflicts if any, then git push.
- Do not suggest
git push --forceunless the user explicitly wants to overwrite remote (e.g. after rebase) and understands the risk; then prefergit push --force-with-lease.
Merge or rebase conflicts
- Symptoms: "CONFLICT (content)" in files, or merge/rebase stops.
- Fix:
1. Open listed conflicted files; resolve <<<<<<<, =======, >>>>>>> sections. 2. git add <resolved-files>. 3. Merge: git commit. Rebase: git rebase --continue.
- To abort:
git merge --abortorgit rebase --abort.
Detached HEAD
- Symptoms: Message says "You are in 'detached HEAD' state".
- Cause: Checked out a commit or tag instead of a branch.
- Fix: Switch back to a branch:
git switch main(or branch name). To keep changes in a new branch:git switch -c new-branch-name.
"Too many untracked files" or accidental add of build artifacts
- Fix:
1. Suggest checking/adding a .gitignore (see assets/gitignore-common.txt). 2. If already staged: git restore --staged . then add/update .gitignore and git add .gitignore and relevant paths only.
Lost commits after reset or mistaken checkout
- Fix:
git reflogto find the commit hash (e.g. "HEAD@{1}" before the bad reset). Thengit checkout <hash>to inspect orgit reset --hard <hash>to restore (warn: destructive).
"branch has no upstream branch" when pushing
- Fix: First push with upstream:
git push -u origin <branch-name>. After that,git pushworks.
Large files / "file exceeds limit" (e.g. GitHub)
- Cause: Host rejects files over a size limit.
- Fix: Remove file from history (e.g.
git filter-branchorgit filter-repo), or use Git LFS. For one-time large file, remove from latest commit:git reset HEAD^ path/to/file, add to.gitignore, thengit commit --amend.
SSL certificate / HTTPS errors
- Cause: Corporate proxy, custom CA, or outdated certs.
- Fix: User may need to set
git config http.sslVerify falsetemporarily (explain security trade-off) or install correct CA. Prefer directing to IT or host docs.
Git Workflows
Step-by-step workflows for common tasks. Use when the user needs a guided sequence beyond single commands.
Daily: see what changed and commit
1. git status — see branch, staged/unstaged/untracked. 2. git diff — review unstaged changes; git diff --staged for staged. 3. git add <paths> or git add . — stage. 4. git commit -m "descriptive message".
Create a feature branch and push
1. Ensure clean state or commit/stash: git status. 2. Update main: git switch main then git pull. 3. Create branch: git switch -c feature/my-feature. 4. Make changes, then: git add . → git commit -m "message". 5. First push: git push -u origin feature/my-feature. 6. Later: git push.
Sync with remote when push is rejected
1. git fetch (or git pull / git pull --rebase). 2. If merge: resolve conflicts if any, then git add and git commit. 3. If rebase: resolve conflicts, git add, then git rebase --continue. 4. git push.
Resolve merge or rebase conflicts
1. Open conflicted files; look for <<<<<<<, =======, >>>>>>>. 2. Edit to keep the correct content and remove markers. 3. git add <resolved-files>. 4. Merge: git commit (message often pre-filled). 5. Rebase: git rebase --continue. Repeat until done.
Stash, switch branch, then restore
1. git stash (optionally git stash push -m "WIP feature X"). 2. git switch other-branch — do other work. 3. git switch feature/x then git stash pop (or git stash apply to keep stash).
Amend last commit (forgot file or fix message)
1. Stage the forgotten file: git add <file>. 2. git commit --amend --no-edit — add to last commit, keep message.
- Or:
git commit --amend -m "New message"to change message.
Release with a tag
1. Commit all changes and push: git push. 2. On the release commit: git tag -a v1.0.0 -m "Release 1.0.0". 3. Push tag: git push origin v1.0.0 or git push origin --tags.
Recover after mistaken reset or checkout
1. git reflog — find the commit hash you want (e.g. before reset --hard). 2. git checkout <hash> to inspect, or git reset --hard <hash> to restore that state (destructive; confirm with user).
Leave detached HEAD
If you checked out a commit or tag and see "detached HEAD":
1. git switch main (or the branch you want) — or create a new branch: git switch -c new-branch.
Merge another branch into current
1. git merge <branch>. 2. If conflicts: resolve in files → git add → git commit. 3. If no conflicts: commit may be created automatically (or run git commit if needed).
Rebase current branch onto main
1. git fetch then git switch main and git pull. 2. git switch feature-branch then git rebase main. 3. On conflict: fix files → git add → git rebase --continue. 4. Push: git push (may need --force-with-lease if branch was already pushed; warn user).
#!/usr/bin/env bash
# List local and remote branches with upstream and last commit.
# Usage: run from repository root.
set -e
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "Not a Git repository."
exit 1
fi
echo "=== Local branches (with upstream and last commit) ==="
git branch -vv
echo ""
echo "=== All branches (local + remote-tracking) ==="
git branch -a
#!/usr/bin/env bash
# Exit 0 if current directory is a Git repo, else 1.
# Usage: run from any directory (e.g. repo root).
# Use from AI: to confirm context before suggesting git commands.
set -e
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
exit 0
else
exit 1
fi
Git CLI Scripts
Run from repository root. Use Git Bash or WSL on Windows.
| Script | Purpose |
|---|---|
is-repo.sh | Exit 0 if cwd is a Git repo, else 1. Use to confirm context. |
status-summary.sh | Branch, upstream, last commit, and short status. |
branch-list.sh | Local branches with upstream + all branches (local + remote). |
Example: bash path/to/scripts/status-summary.sh
#!/usr/bin/env bash
# Print short status: branch, upstream, last commit, and status summary.
# Usage: run from repository root.
set -e
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "Not a Git repository."
exit 1
fi
echo "=== Branch ==="
git status -sb
echo ""
echo "=== Last commit ==="
git log -1 --oneline --decorate
echo ""
echo "=== Status ==="
git status --short
Related skills
FAQ
Does git-cli suggest destructive commands?
No, not unless the user explicitly asks and understands the risk; it prefers read-only commands.
What helper scripts are bundled?
is-repo.sh, status-summary.sh, and branch-list.sh, run from the repository root.