{"id":16003195,"url":"https://github.com/pierredemailly/node-git","last_synced_at":"2026-02-25T06:14:13.205Z","repository":{"id":39713596,"uuid":"507152098","full_name":"PierreDemailly/node-git","owner":"PierreDemailly","description":"Git API for node.js","archived":false,"fork":false,"pushed_at":"2024-03-10T15:39:29.000Z","size":801,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-09T14:05:04.209Z","etag":null,"topics":["git","nodejs"],"latest_commit_sha":null,"homepage":"https://pierredemailly.github.io/node-git/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PierreDemailly.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-24T21:47:54.000Z","updated_at":"2023-12-12T23:42:50.000Z","dependencies_parsed_at":"2024-02-25T22:25:24.817Z","dependency_job_id":"bad2e3a5-4517-4441-9aa1-ac72bd75969f","html_url":"https://github.com/PierreDemailly/node-git","commit_stats":{"total_commits":52,"total_committers":4,"mean_commits":13.0,"dds":"0.40384615384615385","last_synced_commit":"4062303b1934e78171856be79130ac994b10b6eb"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/PierreDemailly/node-git","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreDemailly%2Fnode-git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreDemailly%2Fnode-git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreDemailly%2Fnode-git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreDemailly%2Fnode-git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PierreDemailly","download_url":"https://codeload.github.com/PierreDemailly/node-git/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreDemailly%2Fnode-git/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264257446,"owners_count":23580468,"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":["git","nodejs"],"created_at":"2024-10-08T10:06:39.996Z","updated_at":"2025-10-27T21:03:21.549Z","avatar_url":"https://github.com/PierreDemailly.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e Simple Git API for Node.js (ESM).\n\n[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=for-the-badge)](#contributors-)\n[![npm version](https://img.shields.io/npm/v/@pierred/node-git.svg?style=for-the-badge)](https://npmjs.com/package/@pierred/node-git)\n[![last commit](https://img.shields.io/github/last-commit/pierredemailly/node-git.svg?style=for-the-badge)](https://github.com/PierreDemailly/node-git/commits/main)\n\n## Installation\n\n```\nnpm i @pierred/node-git\n```\n\n## API\n\n### `changesCount()`\nGet the count of changes.\n\nIt does include changes that have been staged, which haven't.\n\nIt does not include changes that are untracked.\n\n```ts\nchangesCount(): Promise\u003cnumber\u003e\n```\n\n### `stagedCount()`\n\nGet the count of changes that have been staged.\n\n```ts\nstagedCount(): Promise\u003cnumber\u003e\n```\n\n### `commit(message[, options])`\nCreate a commit given one or multiple commit message(s).\n\n```ts\ncommit(message: string | string[], options?: { skipHooks: boolean }): Promise\u003cvoid\u003e\n```\nExample usage:\n\n```ts\nawait commit(\"My Commit\"); // execute `git commit -m \"My Commit\"`.\nawait commit([\"My Commit\", \"My Second Commit\"]); // execute `git commit -m \"My Commit\" -m \"My Second Commit\"`.\n```\n\n### `indexAll(options)`\nAdd current changes to the git staging area.\n\n```ts\nindexAll(options?: IndexAllOptions): Promise\u003cvoid\u003e\n```\n### `indexAllCurrentDirectory(options)`\nAdd current changes of the current working directory to the git staging area.\n\n```ts\nindexAllCurrentDirectory(options?: indexAllCurrentDirectoryOptions): Promise\u003cvoid\u003e\n```\nThis method should not be used with Git V2.x without ignoreRemovals: true, because Git V2.x does include deleted files\nby default. Git V1.x side, it doesn't support --ignore-removal flag, deleted files are\nomitted as expected behavior.\n\n### `indexFileOrDirectory(fileOrDirectory)`\nAdd standalone file or directory to the git staging area.\n\n```ts\nindexFileOrDirectory(fileOrDirectory: string): Promise\u003cvoid\u003e\n```\n\n### `indexFilesOrDirectories(filesOrDirectories)`\nAdd multiple files or directories to the git staging area.\n\n```ts\nindexFilesOrDirectories(filesOrDirectories: string[]): Promise\u003cvoid\u003e\n```\n### `logs()`\nGet the list of all commits for the current branch.\n\n```ts\nlogs(): Promise\u003cCommit[]\u003e\n```\n\n### `push()`\nPush to remote.\n\n```ts\npush(): Promise\u003cvoid\u003e\n```\n\n### `restoreFile(file)`\nRemove given file from the git staging area.\n\n```ts\nrestoreFile(file: string): Promise\u003cvoid\u003e\n```\n\n### `currentBranch()`\nRetrieve current branch name.\n\n```ts\ncurrentBranch(): Promise\u003cstring\u003e\n```\n\n### `init()`\nInitialize a git repository.\nIf git is already initialized, it will prompt for a confirmation.\n\n```ts\ninit(): Promise\u003cvoid\u003e;\n```\n\n### `currentAuthor()`\nGet the current author to the format `name \u003cemail\u003e` (based on Git configuration).\n\n```ts\ncurrentAuthor(): Promise\u003cstring\u003e;\n```\n\n## Types\n\n### IndexAllOptions\n```ts\ninterface IndexAllOptions {\n  omitNewFiles: boolean;\n}\n```\nWhether omit to index new files.\nSetting it to true will execute git add -u.\n\n### indexAllCurrentDirectoryOptions\n```ts\ninterface indexAllCurrentDirectoryOptions {\n  ignoreRemovals: boolean;\n}\n```\nWhether omit to index deleted files.\nSetting it to true will execute git add . --ignore-removal.\n\n### CommitMergeResult\n```ts\ninterface CommitMergeResult {\n  from: string;\n  to: string;\n}\n```\nRepresents the result of a merge commit.\n\n### CommitAuthor\n```ts\ninterface CommitAuthor {\n  name: string;\n  email: string;\n}\n```\nRepresents a commit author: name \u0026 email.\n\n### Commit\n```ts\ninterface Commit {\n  commit: string,\n  merged: null | CommitMergeResult,\n  author: CommitAuthor,\n  date: string,\n  message: string[]\n}\n```\nRepresent a commit.\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/PierreDemailly\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/39910767?v=4?s=80\" width=\"80px;\" alt=\"PierreD\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ePierreD\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/PierreDemailly/node-git/commits?author=PierreDemailly\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/PierreDemailly/node-git/commits?author=PierreDemailly\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/SofianD\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/39944043?v=4?s=80\" width=\"80px;\" alt=\"Yefis\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eYefis\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/PierreDemailly/node-git/commits?author=SofianD\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/PierreDemailly/node-git/pulls?q=is%3Apr+reviewed-by%3ASofianD\" title=\"Reviewed Pull Requests\"\u003e👀\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierredemailly%2Fnode-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpierredemailly%2Fnode-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierredemailly%2Fnode-git/lists"}