Socket
Socket
Sign inDemoInstall

current-git-branch

Package Overview
Dependencies
3
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

current-git-branch


Version published
Maintainers
1
Created

Package description

What is current-git-branch?

The `current-git-branch` npm package is a simple utility that allows you to get the name of the current Git branch in a Node.js environment. It is useful for scripts and tools that need to be aware of the current branch context.

What are current-git-branch's main functionalities?

Get Current Git Branch

This feature allows you to retrieve the name of the current Git branch. The code sample demonstrates how to use the `current-git-branch` package to get the branch name and print it to the console.

const currentGitBranch = require('current-git-branch');
const branchName = currentGitBranch();
console.log(branchName);

Other packages similar to current-git-branch

Readme

Source

current-git-branch

Build Status Build status Coverage Status

Get synchronously the current branch name

Installation

$ npm i current-git-branch --save

or

$ yarn add current-git-branch

Usage

Returns:

  • Boolean false: It is not a git repository
  • String: The branch name
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

Keywords

FAQs

Last updated on 16 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc