https://github.com/jpeer264/node-current-git-branch
A tool to get the branch name of a specific directory
https://github.com/jpeer264/node-current-git-branch
branch commit git head is-git nodejs
Last synced: 3 months ago
JSON representation
A tool to get the branch name of a specific directory
- Host: GitHub
- URL: https://github.com/jpeer264/node-current-git-branch
- Owner: JPeer264
- License: mit
- Created: 2017-04-08T08:52:05.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2025-01-15T13:47:57.000Z (6 months ago)
- Last Synced: 2025-03-26T07:11:13.860Z (3 months ago)
- Topics: branch, commit, git, head, is-git, nodejs
- Language: JavaScript
- Size: 220 KB
- Stars: 10
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# current-git-branch
[](https://github.com/JPeer264/node-current-git-branch/actions/workflows/ci.yml?query=branch%3Amain)
[](https://coveralls.io/github/JPeer264/node-current-git-branch?branch=master)Get synchronously the current branch name
## Installation
```sh
$ npm i current-git-branch --save
```## Usage
Returns:
- Boolean `false`: It is not a git repository
- String: The branch name```js
import branchName from "current-git-branch";branchName(); // false or branch name of process.cwd()
branchName({ cwd: "any/git/repo" }); // false or branch name of the directory 'any/git/repo'
branchName({ cwd: "any/git/repo", branchOptions: ["--no-color"] }); // alternatively, you may pass git-branch command options, either as a string or an array
```## LICENSE
MIT © [Jan Peer Stöcklmair](https://www.jpeer.at)