https://github.com/luftywiranda13/git-dir-up
Find the closest `.git` directory
https://github.com/luftywiranda13/git-dir-up
Last synced: about 1 month ago
JSON representation
Find the closest `.git` directory
- Host: GitHub
- URL: https://github.com/luftywiranda13/git-dir-up
- Owner: luftywiranda13
- License: mit
- Created: 2018-01-12T13:45:55.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-03T09:19:39.000Z (about 6 years ago)
- Last Synced: 2025-03-01T17:06:37.905Z (over 1 year ago)
- Language: JavaScript
- Size: 90.8 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# git-dir-up
> Find the closest `.git` directory
[](https://www.npmjs.com/package/git-dir-up)
[](https://npm-stat.com/charts.html?package=git-dir-up&from=2016-04-01)
[](https://travis-ci.org/luftywiranda13/git-dir-up)
[](https://codecov.io/gh/luftywiranda13/git-dir-up)
Useful for tools that need to know whether `git` is managing the things inside.
## Installation
```sh
npm install --save git-dir-up
```
## Usage
```sh
/
└── Users
└── luftywiranda
└── foo
├── .git
└── bar
├── baz
└── example.js
```
```js
// example.js
const gitDirUp = require('git-dir-up');
gitDirUp(__dirname).then(filepath => {
console.log(filepath);
//=> '/Users/luftywiranda/foo/.git'
});
```
## API
### gitDirUp([cwd])
Returns a `Promise` for either the filepath or `null` if it couldn't be found.
#### cwd
Type: `string`
Default: `process.cwd()`
Directory to start from.
## Related
* [git-root-dir](https://github.com/luftywiranda13/git-root-dir) – Find the root directory of a `git` repository
* [pkg-up](https://github.com/sindresorhus/pkg-up) – Find the closest `package.json` file
## License
MIT © [Lufty Wiranda](https://www.luftywiranda.com)