{"id":13526972,"url":"https://github.com/jonschlinkert/parse-git-config","last_synced_at":"2025-04-07T17:10:56.765Z","repository":{"id":27806748,"uuid":"31296104","full_name":"jonschlinkert/parse-git-config","owner":"jonschlinkert","description":"Parse `.git/config` into a JavaScript object. sync or async.","archived":false,"fork":false,"pushed_at":"2018-11-20T07:26:07.000Z","size":56,"stargazers_count":61,"open_issues_count":3,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-16T00:04:28.641Z","etag":null,"topics":["conf","config","git","git-config","gitconfig","javascript","jonschlinkert","js","node","nodejs","parse"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-25T03:54:59.000Z","updated_at":"2024-08-17T04:34:51.000Z","dependencies_parsed_at":"2022-08-25T22:42:31.715Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/parse-git-config","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fparse-git-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fparse-git-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fparse-git-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fparse-git-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/parse-git-config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244620732,"owners_count":20482673,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conf","config","git","git-config","gitconfig","javascript","jonschlinkert","js","node","nodejs","parse"],"created_at":"2024-08-01T06:01:38.661Z","updated_at":"2025-03-24T11:12:59.194Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","readme":"# parse-git-config [![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\u0026label=Travis)](https://travis-ci.org/jonschlinkert/parse-git-config)\n\n\u003e Parse `.git/config` into a JavaScript object. sync or async.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save parse-git-config\n```\n\n## Usage\n\n```js\nconst parse = require('parse-git-config');\n\n// sync\nconsole.log(parse.sync());\n\n// using async/await\n(async () =\u003e console.log(await parse()))();\n```\n\n## Options\n\n### cwd\n\nThe starting directory to search from.\n\n**Type**: `string`\n\n**Default**: `process.cwd()` (current working directory)\n\n### path\n\nEither the absolute path to .git `config`, or the path relative to the current working directory.\n\n**Type**: `string`\n\n**Default**: `.git/config`\n\n### Examples config object\n\nParsed config object will look something like:\n\n```js\n{ core:\n   { repositoryformatversion: '0',\n     filemode: true,\n     bare: false,\n     logallrefupdates: true,\n     ignorecase: true,\n     precomposeunicode: true },\n  'remote \"origin\"':\n   { url: 'https://github.com/jonschlinkert/parse-git-config.git',\n     fetch: '+refs/heads/*:refs/remotes/origin/*' },\n  'branch \"master\"': { remote: 'origin', merge: 'refs/heads/master', ... } }\n```\n\n## API\n\n### [parse](index.js#L42)\n\nAsynchronously parse a `.git/config` file. If only the callback is passed, the `.git/config` file relative to `process.cwd()` is used.\n\n**Params**\n\n* `options` **{Object|String|Function}**: Options with `cwd` or `path`, the cwd to use, or the callback function.\n* `callback` **{Function}**: callback function if the first argument is options or cwd.\n* `returns` **{Object}**\n\n**Example**\n\n```js\nparse((err, config) =\u003e {\n  if (err) throw err;\n  // do stuff with config\n});\n\n// or, using async/await\n(async () =\u003e {\n  console.log(await parse());\n  console.log(await parse({ cwd: 'foo' }));\n  console.log(await parse({ cwd: 'foo', path: 'some/.git/config' }));\n})();\n```\n\n### [.sync](index.js#L88)\n\nSynchronously parse a `.git/config` file. If no arguments are passed, the `.git/config` file relative to `process.cwd()` is used.\n\n**Params**\n\n* `options` **{Object|String}**: Options with `cwd` or `path`, or the cwd to use.\n* `returns` **{Object}**\n\n**Example**\n\n```js\nconsole.log(parse.sync());\nconsole.log(parse.sync({ cwd: 'foo' }));\nconsole.log(parse.sync({ cwd: 'foo', path: 'some/.git/config' }));\n```\n\n### [.expandKeys](index.js#L134)\n\nReturns an object with only the properties that had ini-style keys converted to objects.\n\n**Params**\n\n* `config` **{Object}**: The parsed git config object.\n* `returns` **{Object}**\n\n**Example**\n\n```js\nconst config = parse.sync({ path: '/path/to/.gitconfig' });\nconst obj = parse.expandKeys(config);\n```\n\n### .expandKeys examples\n\nConverts ini-style keys into objects:\n\n**Example 1**\n\n```js\nconst parse = require('parse-git-config');\nconst config = { \n  'foo \"bar\"': { doStuff: true },\n  'foo \"baz\"': { doStuff: true } \n};\n\nconsole.log(parse.expandKeys(config));\n```\n\nResults in:\n\n```js\n{ \n  foo: { \n    bar: { doStuff: true }, \n    baz: { doStuff: true } \n  } \n}\n```\n\n**Example 2**\n\n```js\nconst parse = require('parse-git-config');\nconst config = {\n  'remote \"origin\"': { \n    url: 'https://github.com/jonschlinkert/normalize-pkg.git',\n    fetch: '+refs/heads/*:refs/remotes/origin/*' \n  },\n  'branch \"master\"': { \n    remote: 'origin', \n    merge: 'refs/heads/master' \n  },\n  'branch \"dev\"': { \n    remote: 'origin', \n    merge: 'refs/heads/dev', \n    rebase: true \n  }\n};\n\nconsole.log(parse.expandKeys(config));\n```\n\nResults in:\n\n```js\n{\n  remote: {\n    origin: {\n      url: 'https://github.com/jonschlinkert/normalize-pkg.git',\n      fetch: '+refs/heads/*:refs/remotes/origin/*'\n    }\n  },\n  branch: {\n    master: {\n      remote: 'origin',\n      merge: 'refs/heads/master'\n    },\n    dev: {\n      remote: 'origin',\n      merge: 'refs/heads/dev',\n      rebase: true\n    }\n  }\n}\n```\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [git-user-name](https://www.npmjs.com/package/git-user-name): Get a user's name from git config at the project or global scope, depending on… [more](https://github.com/jonschlinkert/git-user-name) | [homepage](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.\")\n* [git-username](https://www.npmjs.com/package/git-username): Get the username (or 'owner' name) from a git/GitHub remote origin URL. | [homepage](https://github.com/jonschlinkert/git-username \"Get the username (or 'owner' name) from a git/GitHub remote origin URL.\")\n* [parse-author](https://www.npmjs.com/package/parse-author): Parse an author, contributor, maintainer or other 'person' string into an object with name, email… [more](https://github.com/jonschlinkert/parse-author) | [homepage](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.\")\n* [parse-authors](https://www.npmjs.com/package/parse-authors): Parse a string into an array of objects with `name`, `email` and `url` properties following… [more](https://github.com/jonschlinkert/parse-authors) | [homepage](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.\")\n* [parse-github-url](https://www.npmjs.com/package/parse-github-url): Parse a github URL into an object. | [homepage](https://github.com/jonschlinkert/parse-github-url \"Parse a github URL into an object.\")\n* [parse-gitignore](https://www.npmjs.com/package/parse-gitignore): Parse a .gitignore or .npmignore file into an array of patterns. | [homepage](https://github.com/jonschlinkert/parse-gitignore \"Parse a .gitignore or .npmignore file into an array of patterns.\")\n\n### Contributors\n\n| **Commits** | **Contributor** |  \n| --- | --- |  \n| 66 | [jonschlinkert](https://github.com/jonschlinkert) |  \n| 4  | [doowb](https://github.com/doowb) |  \n| 1  | [daviwil](https://github.com/daviwil) |  \n| 1  | [LexSwed](https://github.com/LexSwed) |  \n| 1  | [sam3d](https://github.com/sam3d) |  \n| 1  | [suarasaur](https://github.com/suarasaur) |  \n\n### Author\n\n**Jon Schlinkert**\n\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n\n### License\n\nCopyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on November 20, 2018._","funding_links":[],"categories":["Repository"],"sub_categories":["Git"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fparse-git-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fparse-git-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fparse-git-config/lists"}