# @contentstack/cli-cm-branches 中文文档

规范地址：https://npmcn.com/package/%40contentstack/cli-cm-branches/

版本：2\.0\.2
npm 元数据更新时间：2026-10-06T14:51:04.925Z
中文译文更新时间：2026-11-10T16:47:48.335Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40contentstack/cli-cm-branches
原文对照：https://npmcn.com/package/%40contentstack/cli-cm-branches/?lang=original
项目主页：https://github.com/contentstack/cli
源码仓库：https://github.com/contentstack/cli-plugins

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：234 kB，29 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=22\.0\.0
- 运行依赖：7 个
- 首次发布：2023-05-12T07:01:05.089Z
- 最新版本发布：2026-10-06T14:51:04.725Z
- 近 30 天下载量：44052（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：74（近 12 个月 29 个）

## 中文简介

执行分支操作的内存 CLI 插件

## 安装

```sh
npm install @contentstack/cli-cm-branches
```

也可以使用：`pnpm add @contentstack/cli-cm-branches`、`yarn add @contentstack/cli-cm-branches`、`bun add @contentstack/cli-cm-branches`

## README

# @ contentstack/cli-cm- branches (中文(简体) )

Contack 的 CLI 插件来比较和合并内容 . [![License](https://img.shields.io/npm/l/@contentstack/cli)](https://github.com/contentstack/cli/blob/main/LICENSE)

-   [@ contentstack/cli-cm- branches (中文(简体) )](https://npmcn.com/package/%40contentstack/cli-cm-branches/#readme-contentstackcli-cm-branches)
-   [使用量](https://npmcn.com/package/%40contentstack/cli-cm-branches/#readme-usage)
-   [图标](https://npmcn.com/package/%40contentstack/cli-cm-branches/#readme-commands)

要切换区域,请使用 `csdx config:set:region` 命令,而不是手动编辑配置文件.

# 使用量

```sh-session
$ npm install -g @contentstack/cli-cm-branches
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-branches/2.0.2 linux-x64 node-v22.23.3
$ csdx --help [COMMAND]
USAGE
  $ csdx COMMAND
...
```

# 图标

-   [`csdx cm:branches`](https://npmcn.com/package/%40contentstack/cli-cm-branches/#readme-csdx-cmbranches)
-   [`csdx cm:branches:create`](https://npmcn.com/package/%40contentstack/cli-cm-branches/#readme-csdx-cmbranchescreate)
-   [`csdx cm:branches:delete [-uid <value>] [-k <value>]`](https://npmcn.com/package/%40contentstack/cli-cm-branches/#readme-csdx-cmbranchesdelete--uid-value--k-value)
-   [`csdx cm:branches:diff [--base-branch <value>] [--compare-branch <value>] [-k <value>][--module <value>] [--format <value>] [--csv-path <value>]`](https://npmcn.com/package/%40contentstack/cli-cm-branches/#readme-csdx-cmbranchesdiff---base-branch-value---compare-branch-value--k-value--module-value---format-value---csv-path-value)
-   [`csdx cm:branches:merge [-k <value>][--compare-branch <value>] [--no-revert] [--export-summary-path <value>] [--use-merge-summary <value>] [--comment <value>] [--base-branch <value>]`](https://npmcn.com/package/%40contentstack/cli-cm-branches/#readme-csdx-cmbranchesmerge--k-value--compare-branch-value---no-revert---export-summary-path-value---use-merge-summary-value---comment-value---base-branch-value)
-   [`csdx cm:branches:merge-status -k <value> --merge-uid <value>`](https://npmcn.com/package/%40contentstack/cli-cm-branches/#readme-csdx-cmbranchesmerge-status--k-value---merge-uid-value)

## `csdx cm:branches`

列出分支

```
USAGE
  $ csdx cm:branches

FLAGS
  -k, --stack-api-key=<value>  Stack API key
      --verbose                Verbose, display information in detailed format.

DESCRIPTION
  List the branches

EXAMPLES
  $ csdx cm:branches

  $ csdx cm:branches --verbose

  $ csdx cm:branches -k <stack api key>
```

_参见代码 : [sc/命令/cm/branches/index.ts](https://github.com/contentstack/cli-plugins/blob/main/packages/contentstack-branches/src/commands/cm/branches/index.ts)_

## `csdx cm:branches:create`

创建新分支

```
USAGE
  $ csdx cm:branches:create
  $ csdx cm:branches:create [--source <value>] [--uid <value>] [-k <value>]
  $ csdx cm:branches:create [--source <value>] [--uid <value>] [--stack-api-key <value>]

FLAGS
  -k, --stack-api-key=<value>  Stack API key
      --source=<value>         Source branch from which a new branch is to be created.
      --uid=<value>            Branch UID (unique name) to be created.

DESCRIPTION
  Create a new branch

EXAMPLES
  $ csdx cm:branches:create

  $ csdx cm:branches:create --source main --uid new_branch -k bltxxxxxxxx

  $ csdx cm:branches:create --source main --uid new_branch --stack-api-key bltxxxxxxxx
```

_参见代码 : [sc/命令/cm/branches/创建.ts](https://github.com/contentstack/cli-plugins/blob/main/packages/contentstack-branches/src/commands/cm/branches/create.ts)_

## `csdx cm:branches:delete [-uid <value>] [-k <value>]`

删除分支

```
USAGE
  $ csdx cm:branches:delete [-uid <value>] [-k <value>]
  $ csdx cm:branches:delete [--uid <value>] [--stack-api-key <value>]

FLAGS
  -k, --stack-api-key=<value>  Stack API key
  -y, --yes                    Force the deletion of the branch by skipping the confirmation
      --uid=<value>            Branch UID to be deleted

DESCRIPTION
  Delete a branch

EXAMPLES
  $ csdx cm:branches:delete

  $ csdx cm:branches:delete --uid main -k bltxxxxxxxx

  $ csdx cm:branches:delete --uid main --stack-api-key bltxxxxxxxx

  $ csdx cm:branches:delete --uid main --stack-api-key bltxxxxxxxx --yes
```

_参见代码 : [src/commands/cm/branches/delete.ts (中文(简体) )](https://github.com/contentstack/cli-plugins/blob/main/packages/contentstack-branches/src/commands/cm/branches/delete.ts)_

## `csdx cm:branches:diff [--base-branch <value>] [--compare-branch <value>] [-k <value>][--module <value>] [--format <value>] [--csv-path <value>]`

两个分支之间的差异

```
USAGE
  $ csdx cm:branches:diff [--base-branch <value>] [--compare-branch <value>] [-k <value>][--module <value>] [--format
    <value>] [--csv-path <value>]

FLAGS
  -k, --stack-api-key=<value>   [optional] Provide the stack API key to show the difference between branches.
      --base-branch=<value>     [optional] Base branch (Target branch).
      --compare-branch=<value>  [optional] Compare branch (Source branch).
      --csv-path=<value>        [optional] Custom path for CSV output file. If not provided, will use the current
                                working directory.
      --format=<option>         [default: compact-text] [default: compact-text] [optional] Type of flags to show the
                                difference between two branches. <options: compact-text, detailed-text>
                                <options: compact-text|detailed-text>
      --module=<option>         [optional] Module. <options: content-types, global-fields, all>
                                <options: content-types|global-fields|all>

DESCRIPTION
  Differences between two branches

EXAMPLES
  $ csdx cm:branches:diff

  $ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx"

  $ csdx cm:branches:diff --compare-branch "develop"

  $ csdx cm:branches:diff --compare-branch "develop" --stack-api-key "bltxxxxxxxx"

  $ csdx cm:branches:diff --compare-branch "develop" --module "content-types"

  $ csdx cm:branches:diff --module "content-types" --format "detailed-text"

  $ csdx cm:branches:diff --compare-branch "develop" --format "detailed-text"

  $ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main"

  $ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "develop"

  $ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --module "content-types"

  $ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "develop" --module "content-types"

  $ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "develop" --module "content-types" --format "detailed-text"

  $ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "develop" --module "content-types" --format "compact-text"

  $ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "develop" --module "content-types" --format "detailed-text" --csv-path "./reports/diff-report.csv"
```

_参见代码 : [src/commands/cm/branches/diff.ts (英语)](https://github.com/contentstack/cli-plugins/blob/main/packages/contentstack-branches/src/commands/cm/branches/diff.ts)_

## `csdx cm:branches:merge [-k <value>][--compare-branch <value>] [--no-revert] [--export-summary-path <value>] [--use-merge-summary <value>] [--comment <value>] [--base-branch <value>]`

从分支合并更改

```
USAGE
  $ csdx cm:branches:merge [-k <value>][--compare-branch <value>] [--no-revert] [--export-summary-path <value>]
    [--use-merge-summary <value>] [--comment <value>] [--base-branch <value>]

FLAGS
  -k, --stack-api-key=<value>        [optional] Provide stack API key to show the difference between the branches.
      --base-branch=<value>          [optional] Base branch (Target branch).
      --comment=<value>              [optional] Pass a comment.
      --compare-branch=<value>       [optional] Compare branch (Source branch).
      --export-summary-path=<value>  [optional] Export summary file path.
      --no-revert                    [optional] If passed, will not create the new revert branch.
      --use-merge-summary=<value>    [optional] Path of merge summary file.

DESCRIPTION
  Merge changes from a branch

EXAMPLES
  $ csdx cm:branches:merge --stack-api-key bltxxxxxxxx --compare-branch feature-branch

  $ csdx cm:branches:merge --stack-api-key bltxxxxxxxx --comment "merge comment"

  $ csdx cm:branches:merge -k bltxxxxxxxx --base-branch base-branch

  $ csdx cm:branches:merge --export-summary-path file/path

  $ csdx cm:branches:merge --use-merge-summary file-path

  $ csdx cm:branches:merge -k bltxxxxxxxx --no-revert

  $ csdx cm:branches:merge -k bltxxxxxxxx --compare-branch feature-branch --no-revert
```

_参见代码 : [src/commands/cm/branches/ commerce.ts (中文(简体) )](https://github.com/contentstack/cli-plugins/blob/main/packages/contentstack-branches/src/commands/cm/branches/merge.ts)_

## `csdx cm:branches:merge-status -k <value> --merge-uid <value>`

检查分支合并任务的状况

```
USAGE
  $ csdx cm:branches:merge-status -k <value> --merge-uid <value>

FLAGS
  -k, --stack-api-key=<value>  (required) Provide your stack API key.
      --merge-uid=<value>      (required) Merge job UID to check status for.

DESCRIPTION
  Check the status of a branch merge job

EXAMPLES
  $ csdx cm:branches:merge-status -k bltxxxxxxxx --merge-uid merge_abc123

  $ csdx cm:branches:merge-status --stack-api-key bltxxxxxxxx --merge-uid merge_abc123
```

_参见代码 : [src/commands/cm/branches/commerd-status.ts 互联网档案馆的存檔,存档日期2013-12-02](https://github.com/contentstack/cli-plugins/blob/main/packages/contentstack-branches/src/commands/cm/branches/merge-status.ts)_

## 常见问题

### @contentstack/cli-cm-branches 是什么？

执行分支操作的内存 CLI 插件

### 如何安装 @contentstack/cli-cm-branches？

在项目目录运行 npm install @contentstack/cli-cm-branches，或使用 pnpm add / yarn add / bun add。

### @contentstack/cli-cm-branches 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @contentstack/cli-cm-branches 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @contentstack/cli-cm-branches 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=22\.0\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @contentstack/cli-cm-branches 可以商用吗？

@contentstack/cli-cm-branches 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @contentstack/cli-cm-branches 的下载量有多少？

根据 npm 官方下载统计，@contentstack/cli-cm-branches 在 2026/10/11 – 2026/11/09 这 30 天内被下载 44,052 次，日均约 1,468 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @contentstack/cli-cm-branches 还在维护吗？

最新版本 2\.0\.2 发布于 2026/10/06（1 个月前）；至今共发布 74 个版本，其中过去 12 个月发布了 29 个；首次发布于 2023/05/12。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

