Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonschlinkert/git-branch
Get the current branch for a local git repository
https://github.com/jonschlinkert/git-branch
branch git javascript nodejs
Last synced: 4 days ago
JSON representation
Get the current branch for a local git repository
- Host: GitHub
- URL: https://github.com/jonschlinkert/git-branch
- Owner: jonschlinkert
- License: mit
- Created: 2014-04-04T16:08:52.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-10-28T15:00:35.000Z (about 3 years ago)
- Last Synced: 2024-10-23T09:59:24.997Z (11 days ago)
- Topics: branch, git, javascript, nodejs
- Language: JavaScript
- Homepage: https://github.com/jonschlinkert
- Size: 43.9 KB
- Stars: 91
- Watchers: 4
- Forks: 16
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# git-branch [![NPM version](https://img.shields.io/npm/v/git-branch.svg?style=flat)](https://www.npmjs.com/package/git-branch) [![NPM monthly downloads](https://img.shields.io/npm/dm/git-branch.svg?style=flat)](https://npmjs.org/package/git-branch) [![NPM total downloads](https://img.shields.io/npm/dt/git-branch.svg?style=flat)](https://npmjs.org/package/git-branch) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/git-branch.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/git-branch)
> Get the current branch from the local git repository.
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save git-branch
```## Usage
```js
const branch = require('git-branch');
```Optionally pass the cwd (current working directory) as the first argument.
**Promise**
```js
branch('some/path')
.then(name => console.log('Branch:', name)) //=> 'Branch: master'
.catch(console.error);
```**Callback**
```js
branch(function(err, name) {
if (err) throw err;
console.log('Branch:', name); //=> 'Branch: master'
});
```**Sync**
```js
console.log('Branch:', branch.sync()); //=> 'Branch: master'
```## About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
Running Tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```### Related projects
You might also be interested in these projects:
* [git-add-remote](https://www.npmjs.com/package/git-add-remote): API for adding git remotes. | [homepage](https://github.com/jonschlinkert/git-add-remote "API for adding git remotes.")
* [git-user-name](https://www.npmjs.com/package/git-user-name): Get a user's name from git config at the project or global scope, depending on… [more](https://github.com/jonschlinkert/git-user-name) | [homepage](https://github.com/jonschlinkert/git-user-name "Get a user's name from git config at the project or global scope, depending on what git uses in the current context.")
* [github-base](https://www.npmjs.com/package/github-base): JavaScript wrapper that greatly simplifies working with GitHub's API. | [homepage](https://github.com/jonschlinkert/github-base "JavaScript wrapper that greatly simplifies working with GitHub's API.")### Contributors
| **Commits** | **Contributor** |
| --- | --- |
| 19 | [jonschlinkert](https://github.com/jonschlinkert) |
| 6 | [emilrowland](https://github.com/emilrowland) |### Author
**Jon Schlinkert**
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
* [GitHub Profile](https://github.com/jonschlinkert)
* [Twitter Profile](https://twitter.com/jonschlinkert)### License
Copyright © 2018, [Jon Schlinkert](http://github.com/https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on March 09, 2018._