# @dword-design/parse-git-config 中文文档

规范地址：https://npmcn.com/package/%40dword-design/parse-git-config/

版本：0\.0\.1
npm 元数据更新时间：2025-05-31T15:06:46.409Z
中文译文更新时间：2026-11-13T01:39:31.785Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40dword-design/parse-git-config
原文对照：https://npmcn.com/package/%40dword-design/parse-git-config/?lang=original
项目主页：https://github.com/jonschlinkert/parse-git-config
源码仓库：https://github.com/jonschlinkert/parse-git-config

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

- 包体积（解压后）：15.5 kB，4 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- Node.js 要求：\>=8
- 运行依赖：2 个
- 首次发布：2025-05-31T15:06:45.875Z
- 最新版本发布：2025-05-31T15:06:46.132Z
- 近 30 天下载量：6025（2026-10-13 至 2026-11-11，npm 官方下载统计）
- 已发布版本数：1（近 12 个月 0 个）

## 中文简介

解析 `.git/config` 输入 JavaScript 对象。 同步或同步 .

## 安装

```sh
npm install @dword-design/parse-git-config
```

也可以使用：`pnpm add @dword-design/parse-git-config`、`yarn add @dword-design/parse-git-config`、`bun add @dword-design/parse-git-config`

## README

# 剖析- git- 配置 [![NPM version](https://img.shields.io/npm/v/parse-git-config.svg?style=flat)](https://www.npmjs.com/package/parse-git-config) [![NPM monthly downloads](https://img.shields.io/npm/dm/parse-git-config.svg?style=flat)](https://npmjs.org/package/parse-git-config) [![NPM total downloads](https://img.shields.io/npm/dt/parse-git-config.svg?style=flat)](https://npmjs.org/package/parse-git-config) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/parse-git-config.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/parse-git-config)

> 解析 `.git/config` 输入 JavaScript 对象。 同步或同步 .

请考虑跟随这个项目的作者, [乔恩·斯林克特](https://github.com/jonschlinkert),并考虑主演该项目以显示你的:心:和支持.

## 安装

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

```sh
$ npm install --save parse-git-config
```

## 使用量

```js
const parse = require('parse-git-config');

// sync
console.log(parse.sync());

// using async/await
(async () => console.log(await parse()))();
```

## 选项

### 数据

要搜索的起始目录 .

**类型**数字 : `string`

**默认**数字 : `process.cwd()` (当前工作目录)

### 路径

要么绝对路径去.git `config`,或相对于当前工作目录的路径.

**类型**数字 : `string`

**默认**数字 : `.git/config`

### 示例配置对象

已解析的配置对象将看起来像:

```js
{ core:
   { repositoryformatversion: '0',
     filemode: true,
     bare: false,
     logallrefupdates: true,
     ignorecase: true,
     precomposeunicode: true },
  'remote "origin"':
   { url: 'https://github.com/jonschlinkert/parse-git-config.git',
     fetch: '+refs/heads/*:refs/remotes/origin/*' },
  'branch "master"': { remote: 'origin', merge: 'refs/heads/master', ... } }
```

## API 密码

### [剖析](https://npmcn.com/package/%40dword-design/parse-git-config/index.js#L42)

同步解析 a `.git/config` 文档。 如果只通过回调 `.git/config` 文件相对 `process.cwd()` 已使用.

**参数**

-   `options` **{Object} {String {功能}\\fn方正黑体简体\\fs18\\b1\\bord1\\shad1\\3cH2F2F2F}**选项 `cwd` 或者说 `path`,或调用函数.
-   `callback` **{职能}**: 如果第一个参数是选项或cwd,则召回函数.
-   `returns` **{对象}**

**示例**

```js
parse((err, config) => {
  if (err) throw err;
  // do stuff with config
});

// or, using async/await
(async () => {
  console.log(await parse());
  console.log(await parse({ cwd: 'foo' }));
  console.log(await parse({ cwd: 'foo', path: 'some/.git/config' }));
})();
```

### [.同步](https://npmcn.com/package/%40dword-design/parse-git-config/index.js#L88)

同步解析 a `.git/config` 文档。 如果没有通过辩论 `.git/config` 文件相对 `process.cwd()` 已使用.

**参数**

-   `options` **{对象}**选项 `cwd` 或者说 `path`,或使用cwd.
-   `returns` **{对象}**

**示例**

```js
console.log(parse.sync());
console.log(parse.sync({ cwd: 'foo' }));
console.log(parse.sync({ cwd: 'foo', path: 'some/.git/config' }));
```

### [扩展键](https://npmcn.com/package/%40dword-design/parse-git-config/index.js#L134)

返回一个对象,其属性只包含已转换成对象的ini-tyle密钥.

**参数**

-   `config` **{对象}**:被解析出 git 配置对象.
-   `returns` **{对象}**

**示例**

```js
const config = parse.sync({ path: '/path/to/.gitconfig' });
const obj = parse.expandKeys(config);
```

### .扩展关键字示例

将 Ini 风格密钥转换为对象 :

**实例1**

```js
const parse = require('parse-git-config');
const config = { 
  'foo "bar"': { doStuff: true },
  'foo "baz"': { doStuff: true } 
};

console.log(parse.expandKeys(config));
```

成果:

```js
{ 
  foo: { 
    bar: { doStuff: true }, 
    baz: { doStuff: true } 
  } 
}
```

**实例2**

```js
const parse = require('parse-git-config');
const config = {
  'remote "origin"': { 
    url: 'https://github.com/jonschlinkert/normalize-pkg.git',
    fetch: '+refs/heads/*:refs/remotes/origin/*' 
  },
  'branch "master"': { 
    remote: 'origin', 
    merge: 'refs/heads/master' 
  },
  'branch "dev"': { 
    remote: 'origin', 
    merge: 'refs/heads/dev', 
    rebase: true 
  }
};

console.log(parse.expandKeys(config));
```

成果:

```js
{
  remote: {
    origin: {
      url: 'https://github.com/jonschlinkert/normalize-pkg.git',
      fetch: '+refs/heads/*:refs/remotes/origin/*'
    }
  },
  branch: {
    master: {
      remote: 'origin',
      merge: 'refs/heads/master'
    },
    dev: {
      remote: 'origin',
      merge: 'refs/heads/dev',
      rebase: true
    }
  }
}
```

## 关于

**捐款**

拉出请求和星星总是受欢迎的. 对于错误和特性请求, [请创建一个问题](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/%40dword-design/parse-git-config/.verb.md) 读取我的模板。 )_

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

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

### 相关项目

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

-   [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.")
-   [git 用户名](https://www.npmjs.com/package/git-username): 从 git/ GitHub 远程源代码 URL 中获取用户名( 或“ 所有人” 名称 ) 。 [主页](https://github.com/jonschlinkert/git-username "Get the username (or 'owner' name) from a git/GitHub remote origin URL.")
-   [剖析作者](https://www.npmjs.com/package/parse-author): 将作者、 贡献者、 维护者或其他“ 人物” 字符串分析成有名称、 电子邮件的对象.. [更多](https://github.com/jonschlinkert/parse-author) | [主页](https://github.com/jonschlinkert/parse-author "Parse an author, contributor, maintainer or other 'person' string into an object with name, email and url properties following npm conventions.")
-   [剖析作者](https://www.npmjs.com/package/parse-authors): 将字符串分析为对象数组 `name`, (中文(简体) ), `email` 财务报告和审定财务报表 `url` 属性跟随.. [更多](https://github.com/jonschlinkert/parse-authors) | [主页](https://github.com/jonschlinkert/parse-authors "Parse a string into an array of objects with `name`, `email` and `url` properties following npm conventions. Useful for the `authors` property in package.json or for parsing an AUTHORS file into an array of authors objects.")
-   [剖析- github-url](https://www.npmjs.com/package/parse-github-url): 将一个 github URL 分析为对象 。\\\\\\\\ x [主页](https://github.com/jonschlinkert/parse-github-url "Parse a github URL into an object.")
-   [解析吉他](https://www.npmjs.com/package/parse-gitignore): 将一个.gitignore或.npmignore文件分解为一系列图案. XQ [主页](https://github.com/jonschlinkert/parse-gitignore "Parse a .gitignore or .npmignore file into an array of patterns.")

### 贡献者

| **提交** | **贡献者** |  
| -- -- -- -- -- -- --  
| 66 | [扬施林克特](https://github.com/jonschlinkert) |  
页:1 [鸽子](https://github.com/doowb) |  
| 1 | [大卫](https://github.com/daviwil) |  
| 1 | [莱克萨斯](https://github.com/LexSwed) |  
| 1 | [萨姆3d](https://github.com/sam3d) |  
| 1 | [苏拉绍尔语name](https://github.com/suarasaur) |

### 作者

**乔恩·斯林克特**

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

### 许可证

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

* * *

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

## 常见问题

### @dword-design/parse-git-config 是什么？

解析 \.git/config 输入 JavaScript 对象。 同步或同步 \.

### 如何安装 @dword-design/parse-git-config？

在项目目录运行 npm install @dword-design/parse-git-config，或使用 pnpm add / yarn add / bun add。

### @dword-design/parse-git-config 支持 TypeScript 吗？

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

### @dword-design/parse-git-config 支持 ESM 还是 CommonJS？

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

### @dword-design/parse-git-config 需要什么版本的 Node\.js？

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

### @dword-design/parse-git-config 可以商用吗？

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

### @dword-design/parse-git-config 的下载量有多少？

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

### @dword-design/parse-git-config 还在维护吗？

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

