{"id":17398478,"url":"https://github.com/vweevers/find-gitdir","last_synced_at":"2026-02-02T20:36:32.525Z","repository":{"id":40577112,"uuid":"316823886","full_name":"vweevers/find-gitdir","owner":"vweevers","description":"Find .git directory with support of submodules and --separate-git-dir.","archived":false,"fork":false,"pushed_at":"2023-11-01T04:59:25.000Z","size":13,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-04T23:54:40.878Z","etag":null,"topics":["git","gitdir","nodejs","npm-package","submodules"],"latest_commit_sha":null,"homepage":"","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/vweevers.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-28T21:20:11.000Z","updated_at":"2022-03-01T09:49:43.000Z","dependencies_parsed_at":"2024-10-23T03:24:59.373Z","dependency_job_id":null,"html_url":"https://github.com/vweevers/find-gitdir","commit_stats":{"total_commits":6,"total_committers":2,"mean_commits":3.0,"dds":"0.33333333333333337","last_synced_commit":"ab041eec0a80e5a82df0274815c03594a16e7a11"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/vweevers/find-gitdir","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Ffind-gitdir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Ffind-gitdir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Ffind-gitdir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Ffind-gitdir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vweevers","download_url":"https://codeload.github.com/vweevers/find-gitdir/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Ffind-gitdir/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264211342,"owners_count":23573491,"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","gitdir","nodejs","npm-package","submodules"],"created_at":"2024-10-16T14:57:11.702Z","updated_at":"2026-02-02T20:36:32.520Z","avatar_url":"https://github.com/vweevers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# find-gitdir\n\n**Find `.git` directory with support of submodules, [`--separate-git-dir`](https://git-scm.com/docs/git-init#Documentation/git-init.txt---separate-git-dirltgitdirgt) and [linked worktrees](https://git-scm.com/docs/git-worktree).**\n\n[![npm status](http://img.shields.io/npm/v/find-gitdir.svg)](https://www.npmjs.org/package/find-gitdir)\n[![node](https://img.shields.io/node/v/find-gitdir.svg)](https://www.npmjs.org/package/find-gitdir)\n![Test](https://github.com/vweevers/find-gitdir/workflows/Test/badge.svg?branch=main)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Usage\n\n```js\nconst gitdir = require('find-gitdir')\n```\n\nLet's say we have a git repository at `/example` and that this is our working directory. Its gitdir will commonly be at `/example/.git`.\n\n```js\nawait gitdir() // /example/.git\n```\n\nLet's also say we have a git submodule at `./beep`. Then `find-gitdir` will find a symbolic link at `./beep/.git` pointing to the gitdir `../.git/modules/beep`:\n\n```js\nawait gitdir('./beep') // /example/.git/modules/beep\n```\n\nBy default `find-gitdir` does not look in parent directories. It can be enabled:\n\n```js\nawait gitdir('./node_modules/find-gitdir')       // null\nawait gitdir('./node_modules/find-gitdir', { roam: true }) // /example/.git\n```\n\n## API\n\n### `gitdir([cwd][, options][, callback])`\n\nYields an absolute path to a `.git` directory or `null` if not found, given working directory `cwd` which defaults to `process.cwd()`. If no callback if provided, a promise is returned. Options:\n\n- `roam` (boolean, default `false`): enable looking in parent directories\n- `common` (boolean, default `false`): if `cwd` is a [linked worktree](https://git-scm.com/docs/git-worktree) then return the gitdir of the main worktree (a.k.a. [`$GIT_COMMON_DIR`](https://git-scm.com/docs/gitrepository-layout)) instead of the gitdir of the linked worktree. This can be useful if you need non-worktree files like `config`.\n\nIf `options` is a boolean, it is interpreted as `options.roam` for backwards compatibility.\n\n### `gitdir.sync([cwd][, options])`\n\nSynchronous variant. Returns an absolute path or `null`.\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install find-gitdir\n```\n\n## License\n\n[MIT](LICENSE) © Vincent Weevers\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Ffind-gitdir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvweevers%2Ffind-gitdir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Ffind-gitdir/lists"}