← 返回
开发者工具 中文

Git Cli 1.0.0

Helper for using the Git CLI to inspect, stage, commit, branch, and synchronize code changes. Use when the user wants to understand or perform Git operations...
帮助使用 Git CLI 检查、暂存、提交、分支及同步代码变更。在用户想了解或执行 Git 操作时使用。
kenswj
开发者工具 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 577
下载
💾 12
安装
1
版本
#latest

概述

Git CLI Helper

This skill explains how to use the Git command line for everyday development tasks in a repository.

When to Use

Use this skill when:

  • The user wants to know “what changed” in the working tree.
  • The user wants to stage, unstage, or commit files.
  • The user wants to create or switch branches.
  • The user wants to pull from or push to a remote.
  • The user needs help with stashing, viewing history, or inspecting diffs.

Requirements

  • Git is installed and available on the PATH (for example git --version succeeds).
  • The current directory is either:
  • Inside a Git repository, or
  • A location where the user intends to run git init or git clone.

When uncertain, suggest the user run:

git status

to see whether the current folder is a Git repository.

Safety Guidelines

  • Prefer read-only commands first (git status, git diff, git log) before suggesting changing commands.
  • Avoid destructive suggestions such as:
  • git reset --hard
  • git clean -fdx
  • git push --force
  • Only mention or recommend such commands if the user explicitly asks and understands the risk.

Common Workflows

1. Inspect current state

Check what has changed and whether there are untracked files:

git status

See detailed changes in the working tree:

git diff           # unstaged changes
git diff --staged  # staged (to-be-committed) changes

2. Stage and unstage changes

Stage a specific file:

git add path/to/file

Stage all tracked and untracked changes:

git add .

Unstage a file (keep changes in the working tree):

git restore --staged path/to/file

3. Create commits

Create a commit with a message:

git commit -m "short, descriptive message"

If the user prefers a multi-line message, suggest:

git commit

which opens their editor.

4. Branching and switching

Create and switch to a new branch:

git checkout -b feature/my-branch

Switch to an existing branch:

git checkout main

List local branches:

git branch

5. Synchronize with remote

If the repository already has a remote (for example origin):

  • Fetch latest remote data:
git fetch
  • Pull latest changes into current branch:
git pull
  • Push the current branch and set upstream:
git push -u origin <branch-name>

For subsequent pushes on the same branch:

git push

6. Cloning and initializing

Clone an existing remote repository:

git clone <repo-url>

Initialize a new repository in the current folder:

git init

Optionally add a remote:

git remote add origin <repo-url>

7. Stashing work-in-progress

When the user needs to temporarily put aside local changes:

git stash

List stashes:

git stash list

Apply and keep the top stash:

git stash apply

Apply and drop the top stash:

git stash pop

Viewing History and Blame

Show recent commits (compact format):

git log --oneline --decorate --graph --all

See who last changed each line of a file:

git blame path/to/file

Troubleshooting Tips

  • If Git reports “not a git repository”, suggest:
  • Running commands in the correct project folder, or
  • Initializing with git init (if appropriate), or
  • Cloning with git clone .
  • If a push is rejected because the remote has new commits, suggest:
  • git pull --rebase or git pull (depending on the team’s policy), then retry git push.
  • If there are merge conflicts, explain:
  • The user must edit the conflicted files,
  • Mark conflicts as resolved by git add,
  • Then complete the merge or rebase with git commit or git rebase --continue.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 03:39 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 68 📥 180,474
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 672 📥 324,534
data-analysis

Akshare Stock 1.0.1

kenswj
A股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
★ 1 📥 3,020