Skip to content

安装方式

Git Doctor 支持多种安装方式,选择最适合你的方式开始使用。

VS Code 插件安装

VSIX 文件安装(推荐)

最简单的安装方式,无需网络:

  1. 获取 VSIX 文件

    • 在项目根目录找到 git-doctor-1.0.0.vsix
  2. 安装插件

    • 打开 VS Code
    • Ctrl+Shift+P 打开命令面板
    • 输入 Extensions: Install from VSIX...
    • 选择 VSIX 文件
  3. 重启 VS Code

从源码构建

适合需要修改源码或体验最新功能的用户:

bash
# 1. 克隆仓库
git clone https://github.com/git-doctor/git-doctor.git
cd git-doctor

# 2. 安装依赖
npm install

# 3. 编译 TypeScript
npm run compile

# 4. 打包 VSIX
npm run package

# 5. 生成的 .vsix 文件在项目根目录

开发模式

适合插件开发者:

bash
# 安装依赖
npm install

# 启动监听模式
npm run watch

# 按 F5 启动调试

CLI 命令行安装

全局安装

bash
# NPM 安装
npm install -g git-doctor

# 验证安装
git-doctor --version

项目本地安装

bash
# 作为开发依赖
npm install --save-dev git-doctor

# 使用 npx 运行
npx git-doctor analyze

从源码安装

bash
# 克隆并全局链接
git clone https://github.com/git-doctor/git-doctor.git
cd git-doctor
npm install
npm run compile
npm link

# 现在可以全局使用
git-doctor analyze

可选依赖

Gitleaks(敏感信息检测增强)

Git Doctor 内置了敏感信息检测功能,但安装 Gitleaks 可以获得更专业的检测能力:

macOS:

bash
brew install gitleaks

Windows:

bash
# 使用 Scoop
scoop install gitleaks

# 或下载二进制文件
# https://github.com/gitleaks/gitleaks/releases

Linux:

bash
# 下载二进制
wget https://github.com/gitleaks/gitleaks/releases/download/v8.18.0/gitleaks_8.18.0_linux_x64.tar.gz
tar -xzf gitleaks_8.18.0_linux_x64.tar.gz
sudo mv gitleaks /usr/local/bin/

AI 功能配置

使用 AI 功能需要配置 API Key:

  1. DeepSeek(推荐)

  2. Kimi(月之暗面)

配置方式:

bash
# VS Code 设置
# 搜索 gitDoctor.ai.apiKey

# 或 CLI
git-doctor ai --api-key YOUR_API_KEY

验证安装

VS Code 插件

  1. 打开任意 Git 仓库
  2. 侧边栏应出现 Git Doctor 图标
  3. 点击运行诊断,确认功能正常

CLI

bash
# 检查版本
git-doctor --version

# 运行诊断测试
cd any-git-repo
git-doctor analyze

常见问题

插件未显示图标

  • 确保当前工作区包含 .git 目录
  • 尝试重启 VS Code
  • 检查插件是否已启用

CLI 命令找不到

bash
# 检查全局安装路径
npm root -g

# 确保路径在 PATH 中
echo $PATH

权限问题

bash
# Linux/macOS 可能需要
sudo npm install -g git-doctor

# 或使用 npx 避免全局安装
npx git-doctor analyze

基于 MIT 许可发布