{"id":15408896,"url":"https://github.com/antongolub/git-root","last_synced_at":"2025-04-19T09:45:47.001Z","repository":{"id":38449301,"uuid":"334697014","full_name":"antongolub/git-root","owner":"antongolub","description":"Find the closest .git containing path","archived":false,"fork":false,"pushed_at":"2025-03-15T17:32:13.000Z","size":7570,"stargazers_count":1,"open_issues_count":8,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-16T03:55:52.634Z","etag":null,"topics":["git","util"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/antongolub.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,"zenodo":null}},"created_at":"2021-01-31T16:08:53.000Z","updated_at":"2025-01-22T14:10:50.000Z","dependencies_parsed_at":"2024-05-07T04:25:42.745Z","dependency_job_id":"7b69ba5d-3c0a-4c8b-88b1-de5beebcccbd","html_url":"https://github.com/antongolub/git-root","commit_stats":{"total_commits":101,"total_committers":7,"mean_commits":"14.428571428571429","dds":0.6534653465346535,"last_synced_commit":"12dcbb60b42905692eee0dea14d6cf57bb6e787d"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":"qiwi/blank-ts-repo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antongolub%2Fgit-root","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antongolub%2Fgit-root/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antongolub%2Fgit-root/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antongolub%2Fgit-root/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antongolub","download_url":"https://codeload.github.com/antongolub/git-root/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249666961,"owners_count":21308157,"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","util"],"created_at":"2024-10-01T16:35:42.564Z","updated_at":"2025-04-19T09:45:46.941Z","avatar_url":"https://github.com/antongolub.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @antongolub/git-root\nFind the closest .git containing path — the git root.\n\n[![CI](https://github.com/antongolub/git-root/workflows/CI/badge.svg)](https://github.com/antongolub/git-root/actions)\n[![Maintainability](https://api.codeclimate.com/v1/badges/77d281e69a451680e1d1/maintainability)](https://codeclimate.com/github/antongolub/git-root/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/77d281e69a451680e1d1/test_coverage)](https://codeclimate.com/github/antongolub/git-root/test_coverage)\n[![npm (scoped)](https://img.shields.io/npm/v/@antongolub/git-root)](https://www.npmjs.com/package/@antongolub/git-root)\n\n## Motivation\nIt's known for certain the best way to find git root:\n```shell\ngit rev-parse --show-toplevel\n```\nHowever, if `git` executable or `child_process.exec` are not available for some (security?) reasons, it's  advisable to use tools like this one.\nInspired by [pkg-dir](https://github.com/sindresorhus/pkg-dir).\n\n## Features\n* Searches for `.git` up the dir tree\n* Handles `gitdir: \u003c/some/path.git\u003e` redirects \n* TS and Flow typings out of box\n* Sync/async methods\n\n## Install\n```shell\nyarn add @antongolub/git-root\n```\n\n## Usage\n```ts\nimport { gitRoot, gitRootSync } from '@antongolub/git-root'\n\n// async\nconst gitRoot1 = await gitRoot('/optional/cwd/path/')\n\n// sync\nconst gitRoot2 = gitRoot('/defaults/to/process/cwd/', true)\n\n// sync too\nconst gitRoot3 = gitRoot.sync()\n\n// `gitRootSync` is an alias for `gitRoot.sync`\nconst gitRoot4 = gitRootSync()\n```\n\n## Alternatives\n\n* [find-git-root](https://github.com/banyudu/find-git-root)\n* [git-root](https://github.com/JPeer264/node-git-root)\n* [git-toplevel](https://github.com/royriojas/git-toplevel)\n* [git-root-path](https://github.com/VishnuTSuresh/git-root-path)\n\n## License\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantongolub%2Fgit-root","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantongolub%2Fgit-root","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantongolub%2Fgit-root/lists"}