{"id":17862601,"url":"https://github.com/tobiasbueschel/git-is-branch-protected-cli","last_synced_at":"2026-02-04T07:41:05.050Z","repository":{"id":50758740,"uuid":"183897737","full_name":"tobiasbueschel/git-is-branch-protected-cli","owner":"tobiasbueschel","description":"🔒 CLI to check whether the current Git branch is protected (i.e. is main or develop)","archived":false,"fork":false,"pushed_at":"2023-06-22T00:59:30.000Z","size":20,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-12T22:05:43.581Z","etag":null,"topics":["branch","cli","conventional","git","husky","protection"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tobiasbueschel.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"tobiasbueschel"}},"created_at":"2019-04-28T11:12:21.000Z","updated_at":"2023-03-24T05:39:41.000Z","dependencies_parsed_at":"2024-11-28T10:15:25.057Z","dependency_job_id":null,"html_url":"https://github.com/tobiasbueschel/git-is-branch-protected-cli","commit_stats":{"total_commits":19,"total_committers":5,"mean_commits":3.8,"dds":0.5789473684210527,"last_synced_commit":"443fe4910fb76f933cf8c96063931fdf8ed01f1f"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tobiasbueschel/git-is-branch-protected-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobiasbueschel%2Fgit-is-branch-protected-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobiasbueschel%2Fgit-is-branch-protected-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobiasbueschel%2Fgit-is-branch-protected-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobiasbueschel%2Fgit-is-branch-protected-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tobiasbueschel","download_url":"https://codeload.github.com/tobiasbueschel/git-is-branch-protected-cli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobiasbueschel%2Fgit-is-branch-protected-cli/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265091734,"owners_count":23710033,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["branch","cli","conventional","git","husky","protection"],"created_at":"2024-10-28T08:53:30.354Z","updated_at":"2026-02-04T07:41:00.012Z","avatar_url":"https://github.com/tobiasbueschel.png","language":"JavaScript","funding_links":["https://github.com/sponsors/tobiasbueschel"],"categories":[],"sub_categories":[],"readme":"# git-is-branch-protected-cli\n\n[![Build Status](https://img.shields.io/travis/tobiasbueschel/git-is-branch-protected-cli/master.svg?style=flat-square)](https://travis-ci.com/tobiasbueschel/git-is-branch-protected-cli)\n[![version](https://img.shields.io/npm/v/git-is-branch-protected-cli.svg?style=flat-square)](http://npm.im/git-is-branch-protected-cli)\n[![downloads](https://img.shields.io/npm/dm/git-is-branch-protected-cli.svg?style=flat-square)](http://npm-stat.com/charts.html?package=git-is-branch-protected-cli)\n[![codecov](https://img.shields.io/codecov/c/github/tobiasbueschel/git-is-branch-protected-cli.svg?style=flat-square)](https://codecov.io/gh/tobiasbueschel/git-is-branch-protected-cli?branch=master)\n\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)\n[![MIT License](https://img.shields.io/npm/l/git-is-branch-protected-cli.svg?style=flat-square)](http://opensource.org/licenses/MIT)\n\n\u003e CLI to check whether current Git branch is protected\n\n## Install\n\n```sh\nnpm install --global git-is-branch-protected-cli\n```\n\n## Usage\n\n```sh\ngibp --help\n\n  Usage\n    gibp [options]\n\n  Options\n    --protected-branches, -b Specify protected branches [Default: master, main, develop]\n    --silent, -s Do not show any error messages\n\n  Examples\n    gibp -b \"master, main, develop, another-important-branch\"\n    gibp -b master\n```\n\n## Why use this tool?\n\nIt's easy to forget setting up branch protection on GitHub, GitLab or any other Git hosting service, and before you know it, you've pushed to `master` during your late night coding session. Or perhaps you have scripted automatic updates that will push and create pull requests to several repositories at once and want to ensure you're not pushing to the wrong branch?\n\nThis tool comes to the rescue and with the help of [Git Hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) and [husky](https://github.com/typicode/husky) prevents you from accidentally pushing to your remote `master`, `main` or `develop` branch. All you need to do is install `husky` and `git-is-branch-protected-cli` to your project:\n\n```sh\nnpm install husky git-is-branch-protected-cli --save-dev\n```\n\nand add the following to your `package.json` to protect anyone from commiting to `master`, `main`, or `develop`:\n\n```json\n{\n  \"husky\": {\n    \"hooks\": {\n      \"pre-push\": \"gibp\"\n    }\n  }\n}\n```\n\nyou can also instruct `gipb` to project other branches using the following configuration as an example:\n\n```json\n{\n  \"husky\": {\n    \"hooks\": {\n      \"pre-push\": \"gibp -b \\\"master, main, develop, foo-bar\\\"\"\n    }\n  }\n}\n```\n\nAfter this setup, the `pre-push` hook will fail if you are on a protected branch as `gibp` returns exit code `1`, thereby preventing you from accidentally pushing to the wrong remote branch.\n\n:warning: This is not a bulletproof solution as someone could still write to the branch using `--no-verify`. Therefore, please also consider setting up server-side branch protection.\n\n## Related\n\n- [git-is-branch-protected](https://github.com/tobiasbueschel/git-is-branch-protected) - API for this CLI.\n- [git-push-pr](https://github.com/tobiasbueschel/git-push-pr) - Push and open pull request in your default browser.\n\n## License\n\nMIT © [Tobias Büschel](https://github.com/tobiasbueschel)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobiasbueschel%2Fgit-is-branch-protected-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobiasbueschel%2Fgit-is-branch-protected-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobiasbueschel%2Fgit-is-branch-protected-cli/lists"}