https://github.com/tobiasbueschel/git-is-branch-protected
🔒Checks whether current Git branch is protected
https://github.com/tobiasbueschel/git-is-branch-protected
bitbucket branch conventional git git-flow github gitlab
Last synced: 3 months ago
JSON representation
🔒Checks whether current Git branch is protected
- Host: GitHub
- URL: https://github.com/tobiasbueschel/git-is-branch-protected
- Owner: tobiasbueschel
- License: mit
- Created: 2019-04-28T10:47:32.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-04-30T17:56:37.000Z (about 6 years ago)
- Last Synced: 2025-10-24T23:44:34.379Z (9 months ago)
- Topics: bitbucket, branch, conventional, git, git-flow, github, gitlab
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- License: license
Awesome Lists containing this project
README
# git-is-branch-protected
[](https://travis-ci.com/tobiasbueschel/git-is-branch-protected)
[](http://npm.im/git-is-branch-protected)
[](http://npm-stat.com/charts.html?package=git-is-branch-protected)
[](https://codecov.io/gh/tobiasbueschel/git-is-branch-protected?branch=master)
[](https://github.com/semantic-release/semantic-release)
[](http://opensource.org/licenses/MIT)
> Checks whether current Git branch is protected
## Install
```
$ npm install git-is-branch-protected
```
## Usage
```js
const gitIsBranchProtected = require('git-is-branch-protected')
(async () => {
// currently on "master" branch
await gitIsBranchProtected()
//=> true
await gitIsBranchProtected('master')
//=> true
await gitIsBranchProtected('develop')
//=> true
await gitIsBranchProtected('feat/add-something')
//=> false
await gitIsBranchProtected('develop', ['master'])
//=> false
await gitIsBranchProtected('develop', ['master, develop'])
//=> true
await gitIsBranchProtected('DEVELOP', ['master, develop'], { caseSensitive: true })
//=> false
})()
```
## API
### gitIsBranchProtected([currentBranch], [protectedBranches], [options])
Returns `true` or `false` indicating whether a branch is _protected_.
#### currentBranch
Type: `string`
The name of the current branch. Defaults to check the actual branch name of the current directory.
#### protectedBranches
Type: `Array`
Default: `['master', 'develop']`
Which branches you would like to protect. By default, `master` and `develop` are protected.
#### options
Type: `Object`
##### caseSensitive
Type: `boolean`
Default: `false`
Whether the check should be performed case sensitive.
## Related
- [git-is-branch-protected-cli](https://github.com/tobiasbueschel/git-is-branch-protected-cli) - CLI for this project.
- [git-push-pr](https://github.com/tobiasbueschel/git-push-pr) - Push and open pull request in your default browser.
## License
MIT © [Tobias Büschel](https://github.com/tobiasbueschel)