https://github.com/tiaanduplessis/enforce-branch-name
Little utility to be used in conjunction with Husky to enforce a branch naming convention
https://github.com/tiaanduplessis/enforce-branch-name
git git-hook husky
Last synced: 10 months ago
JSON representation
Little utility to be used in conjunction with Husky to enforce a branch naming convention
- Host: GitHub
- URL: https://github.com/tiaanduplessis/enforce-branch-name
- Owner: tiaanduplessis
- License: mit
- Created: 2019-03-27T13:02:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-06T15:51:05.000Z (almost 3 years ago)
- Last Synced: 2025-08-30T19:49:36.163Z (11 months ago)
- Topics: git, git-hook, husky
- Language: JavaScript
- Size: 47.9 KB
- Stars: 10
- Watchers: 2
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# enforce-branch-name
[](https://npmjs.org/package/enforce-branch-name)
[](https://npmjs.org/package/enforce-branch-name)
[](https://github.com/RichardLitt/standard-readme)
[](https://npmjs.org/package/enforce-branch-name)
[](http://makeapullrequest.com)
> Little utility to enforce a branch naming convention
## Table of Contents
- [enforce-branch-name](#enforce-branch-name)
- [Table of Contents](#table-of-contents)
- [Install](#install)
- [Usage](#usage)
- [With husky](#with-husky)
- [Contributing](#contributing)
- [License](#license)
## Install
With `npm`:
```sh
npm install --save-dev enforce-branch-name
```
With `yarn`:
```sh
yarn add -D enforce-branch-name
```
With `pnpm`:
```sh
pnpm add -D enforce-branch-name
```
## Usage
Enforce that a branch starts with the prefix `hotfix/`, `bugfix/` or `/feature`. Ignore this check if on the `staging` branch:
```sh
enforce-branch-name '(hotfix|bugfix|feature)\/.+' --ignore 'staging'
```
### With husky
First make sure [`husky`](https://github.com/typicode/husky) is installed and configured. Then configure your hook pre-push hook:
```
// package.json
{
"husky": {
"hooks": {
"pre-push": "enforce-branch-name '(hotfix|bugfix|feature)\/.+' --ignore 'staging'",
}
}
}
```
## Contributing
Got an idea for a new feature? Found a bug? Contributions are welcome! Please [open up an issue](https://github.com/tiaanduplessis/enforce-branch-name/issues) or [make a pull request](https://makeapullrequest.com/).
## License
[MIT © Tiaan du Plessis](./LICENSE)