npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wetoria/git-subtree-cli

v1.2.0

Published

Git Subtree 管理工具 - 支持交互式菜单和批量操作

Downloads

14

Readme

@wetoria/git-subtree-cli

Git Subtree 管理工具 - 支持交互式菜单和批量操作

功能特性

  • 🎯 交互式 CLI 菜单 - 友好的命令行界面
  • 📦 批量操作 - 支持批量添加 remote、批量推送/拉取
  • 🔍 状态检查 - 显示 remote 是否存在
  • 🎨 彩色输出 - 清晰的视觉反馈
  • ⚙️ 灵活配置 - 通过 JSON 配置文件管理多个 subtree

安装

全局安装

npm install -g @wetoria/git-subtree-cli
# 或
pnpm add -g @wetoria/git-subtree-cli
# 或
yarn global add @wetoria/git-subtree-cli

项目内使用(推荐)

npm install -D @wetoria/git-subtree-cli
# 或
pnpm add -D @wetoria/git-subtree-cli

然后在 package.json 中添加脚本:

{
  "scripts": {
    "subtree": "git-subtree"
  }
}

使用 npx(无需安装)

npx @wetoria/git-subtree-cli

使用方法

快速开始(推荐)

使用 init 命令快速初始化:

# 使用 npx(无需安装)
npx @wetoria/git-subtree-cli init

# 或全局安装后
npm install -g @wetoria/git-subtree-cli
git-subtree init

init 命令会自动:

  • ✅ 创建 .git-subtree-config.json 配置文件(如果不存在)
  • ✅ 在 package.json 中添加 subtree 脚本(如果不存在)

手动配置

1. 创建配置文件

在项目根目录创建 .git-subtree-config.json 文件:

{
  "subtree-name": {
    "name": "subtree-name",
    "remote": "https://github.com/user/repo.git",
    "remoteName": "remote-name",
    "branch": "main",
    "prefix": "path/to/subtree",
    "description": "描述信息"
  },
  "another-subtree": {
    "name": "another-subtree",
    "remote": "https://github.com/user/another-repo.git",
    "remoteName": "another-remote",
    "branch": "main",
    "prefix": "path/to/another",
    "description": "另一个 subtree 的描述"
  }
}

2. 运行工具

git-subtree
# 或
gitsbt
# 或
pnpm subtree
# 或
npm run subtree

3. 选择操作

工具会显示交互式菜单:

╔═══════════════════════════════════════╗
║   Git Subtree 管理工具                ║
╚═══════════════════════════════════════╝

📦 Subtree 配置列表:

1. subtree-name [✓]
   描述: 描述信息
   路径: path/to/subtree
   Remote: remote-name -> https://github.com/user/repo.git
   分支: main

操作选项:
  1. 添加/更新 remote
  2. 添加 subtree
  3. 拉取 subtree
  4. 推送 subtree
  5. 批量操作所有
  0. 退出

配置说明

配置文件字段

  • name: subtree 名称(用于显示)
  • remote: 远程仓库 URL
  • remoteName: Git remote 名称
  • branch: 分支名称(如 main, master)
  • prefix: 本地路径前缀
  • description: 描述信息(可选)

配置文件位置

工具会按以下顺序查找配置文件:

  1. 项目根目录的 .git-subtree-config.json
  2. 项目根目录的 git-subtree-config.json
  3. 当前目录的 .git-subtree-config.json
  4. 当前目录的 git-subtree-config.json

功能说明

1. 添加/更新 remote

添加或更新 Git remote,用于 subtree 操作。

2. 添加 subtree

将远程仓库添加为 subtree(首次添加时使用)。

3. 拉取 subtree

从远程仓库拉取最新更改。

4. 推送 subtree

将本地更改推送到远程仓库。

5. 批量操作

批量执行操作,适用于管理多个 subtree。

示例

示例 1: 添加新的 subtree

  1. 在配置文件中添加配置
  2. 运行 git-subtree
  3. 选择 "1. 添加/更新 remote"
  4. 选择 "2. 添加 subtree"

示例 2: 批量拉取所有 subtree

  1. 运行 git-subtree
  2. 选择 "5. 批量操作所有"
  3. 选择 "3. 批量拉取所有 subtree"

要求

  • Node.js >= 18.0.0
  • Git(已安装并配置)

License

MIT

Author

Wetoria