Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 1 month 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-16T12:39:23.000Z (about 6 years ago)
- Last Synced: 2024-11-11T18:48:24.547Z (about 1 month ago)
- Topics: branch, commit, git, head, is-git, nodejs
- Language: JavaScript
- Size: 82 KB
- Stars: 10
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# current-git-branch
[![Build Status](https://travis-ci.org/JPeer264/node-current-git-branch.svg?branch=master)](https://travis-ci.org/JPeer264/node-current-git-branch)
[![Build status](https://ci.appveyor.com/api/projects/status/ehj6762gbj1e2qyc?svg=true)](https://ci.appveyor.com/project/JPeer264/node-current-git-branch)
[![Coverage Status](https://coveralls.io/repos/github/JPeer264/node-current-git-branch/badge.svg?branch=master)](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
```
or
```sh
$ yarn add current-git-branch
```## Usage
Returns:
- Boolean `false`: It is not a git repository
- String: The branch name```js
const branchName = require('current-git-branch');branchName(); // false or branch name of process.cwd()
branchName({ altPath: 'any/git/repo' }); // false or branch name of the directory 'any/git/repo'
branchName({ altPath: '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)