https://github.com/vweevers/is-git-branch-name-valid
Check that a git branch name is well formed.
https://github.com/vweevers/is-git-branch-name-valid
branch git nodejs npm-package refname
Last synced: 4 months ago
JSON representation
Check that a git branch name is well formed.
- Host: GitHub
- URL: https://github.com/vweevers/is-git-branch-name-valid
- Owner: vweevers
- License: mit
- Created: 2020-11-28T19:34:57.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-11-01T10:06:39.000Z (over 2 years ago)
- Last Synced: 2025-04-06T08:43:22.329Z (about 1 year ago)
- Topics: branch, git, nodejs, npm-package, refname
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# is-git-branch-name-valid
**Check that a git branch name is well formed.**
[](https://www.npmjs.org/package/is-git-branch-name-valid)
[](https://www.npmjs.org/package/is-git-branch-name-valid)

[](https://standardjs.com)
## Usage
```js
const validBranch = require('is-git-branch-name-valid')
validBranch('foo.bar') // true
validBranch('foo-bar/baz') // true
validBranch('foo^bar') // false
validBranch('HEAD') // false
validBranch('-foo') // false
```
## API
### `validBranch(name)`
Takes a string `name`. Returns true if `name`:
1. Is a [valid reference name](https://github.com/vweevers/is-git-ref-name-valid)
2. Does not equal `HEAD` or start with `-`.
## Install
With [npm](https://npmjs.org) do:
```
npm install is-git-branch-name-valid
```
## License
[MIT](LICENSE) © Vincent Weevers