# @fork-of/git-branch 中文文档

规范地址：https://npmcn.com/package/%40fork-of/git-branch/

版本：2\.1\.1
npm 元数据更新时间：2022-04-05T11:50:29.447Z
中文译文更新时间：2026-11-15T07:58:28.723Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40fork-of/git-branch
原文对照：https://npmcn.com/package/%40fork-of/git-branch/?lang=original
项目主页：https://github.com/joscha/git-branch
源码仓库：https://github.com/joscha/git-branch

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

- 包体积（解压后）：7 kB，4 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- Node.js 要求：\>=8
- 运行依赖：1 个
- 首次发布：2021-11-11T04:18:04.803Z
- 最新版本发布：2021-11-11T04:21:14.490Z
- 近 30 天下载量：454793（2026-10-16 至 2026-11-14，npm 官方下载统计）
- 已发布版本数：2（近 12 个月 0 个）

## 中文简介

从本地 git 仓库获取当前分支 。 希望是临时叉子 [https://github.com/jonschlinkert/git-branch/ (中文(简体) )](https://github.com/jonschlinkert/git-branch/)

## 安装

```sh
npm install @fork-of/git-branch
```

也可以使用：`pnpm add @fork-of/git-branch`、`yarn add @fork-of/git-branch`、`bun add @fork-of/git-branch`

## README

# @fork-of/git-branch (英语) [![NPM version](https://img.shields.io/npm/v/@fork-of/git-branch.svg?style=flat)](https://www.npmjs.com/package/@fork-of/git-branch) [![NPM monthly downloads](https://img.shields.io/npm/dm/@fork-of/git-branch.svg?style=flat)](https://npmjs.org/package/@fork-of/git-branch) [![NPM total downloads](https://img.shields.io/npm/dt/@fork-of/git-branch.svg?style=flat)](https://npmjs.org/package/@fork-of/git-branch) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/@fork-of/git-branch.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/@fork-of/git-branch)

> 从本地 git 仓库获取当前分支 .

> 希望临时失效 [https://github.com/jonschlinkert/git-branch (中文(简体) )](https://github.com/jonschlinkert/git-branch)

## 安装

安装方式 [无](https://www.npmjs.com/)数字 :

```sh
$ npm install --save @fork-of/git-branch
```

## 使用量

```js
const branch = require('@fork-of/git-branch');
```

可选通过 cwd(当前工作目录)作为第一个参数.

**答应**

```js
branch('some/path')
  .then(name => console.log('Branch:', name)) //=> 'Branch: master'
  .catch(console.error);
```

**回电**

```js
branch(function(err, name) {
  if (err) throw err;
  console.log('Branch:', name); //=> 'Branch: master'
});
```

**同步**

```js
console.log('Branch:', branch.sync()); //=> 'Branch: master'
```

## 关于

**捐款**

拉出请求和星星总是受欢迎的. 对于错误和特性请求, [请创建一个问题](https://npmcn.com/package/issues/new)。 。 。 .

**运行测试**

运行和审查单元测试是熟悉图书馆及其API的好办法。 您可以使用以下命令安装依赖性并运行测试:

```sh
$ npm install && npm test
```
**大楼文件**

_(此工程的 readme.md 由 [动词](https://github.com/verbose/verb-generate-readme)请不要直接编辑读取器。 读取器的任何改动必须在 [动词 md](https://npmcn.com/package/%40fork-of/git-branch/.verb.md) 读取我的模板。 )_

要生成读取, 请运行以下命令 :

```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```

### 相关项目

您可能也对这些项目感兴趣:

-   [git- 添加远程](https://www.npmjs.com/package/git-add-remote): 用于添加 git 远程的 API. QQ [主页](https://github.com/jonschlinkert/git-add-remote "API for adding git remotes.")
-   [git 用户名](https://www.npmjs.com/package/git-user-name):根据 [更多](https://github.com/jonschlinkert/git-user-name) | [主页](https://github.com/jonschlinkert/git-user-name "Get a user's name from git config at the project or global scope, depending on what git uses in the current context.")
-   [基数](https://www.npmjs.com/package/github-base): JavaScript 包装器,大大简化了与 GitHub 的 API 的合作. QQ [主页](https://github.com/jonschlinkert/github-base "JavaScript wrapper that greatly simplifies working with GitHub's API.")

### 贡献者

| **提交** | **贡献者** | | -- -- -- -- -- -- -- 19岁 [扬施林克特](https://github.com/jonschlinkert) | 6个 [绿地](https://github.com/emilrowland) |

### 作者

**乔恩·斯林克特**

-   [链接到配置文件](https://linkedin.com/in/jonschlinkert)
-   [GitHub 配置文件](https://github.com/jonschlinkert)
-   [推特简介](https://twitter.com/jonschlinkert)

### 许可证

版权: 2018, [乔恩·斯林克特](http://github.com/https://github.com/jonschlinkert)。 。 。 . 释放 [MIT 许可证](https://npmcn.com/package/%40fork-of/git-branch/LICENSE)。 。 。 .

* * *

_此文件由 [动词基因读取器](https://github.com/verbose/verb-generate-readme), v 6.0,于2018年3月09日查阅._

## 常见问题

### @fork-of/git-branch 是什么？

从本地 git 仓库获取当前分支 。 希望是临时叉子 https://github\.com/jonschlinkert/git-branch/ \(中文\(简体\) \)

### 如何安装 @fork-of/git-branch？

在项目目录运行 npm install @fork-of/git-branch，或使用 pnpm add / yarn add / bun add。

### @fork-of/git-branch 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/fork-of\_\_git-branch 是否存在。

### @fork-of/git-branch 支持 ESM 还是 CommonJS？

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

### @fork-of/git-branch 需要什么版本的 Node\.js？

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

### @fork-of/git-branch 可以商用吗？

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

### @fork-of/git-branch 的下载量有多少？

根据 npm 官方下载统计，@fork-of/git-branch 在 2026/10/16 – 2026/11/14 这 30 天内被下载 454,793 次，日均约 15,160 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @fork-of/git-branch 还在维护吗？

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

