DEV Community

Cover image for ๐Ÿš€ Introducing cnb: A Simple Tool to Enforce Git Branch Naming Conventions
Amir
Amir

Posted on

๐Ÿš€ Introducing cnb: A Simple Tool to Enforce Git Branch Naming Conventions

What is cnb?

cnb is a customizable CLI tool designed to help teams and developers create Git branches with consistent naming conventions effortlessly. Instead of manually typing branch names, cnb prompts you to select a branch type and add a description, automatically formatting it to a standardized branch name.

Why Do You Need It?

Maintaining consistent branch naming across projects can be challenging, especially in large teams. Poorly named branches lead to confusion and disrupt workflows. cnb solves this by enforcing your teamโ€™s naming conventions, making it easier to track, organize, and review branches. This tool is perfect for teams using Git who want to establish a clean, standardized workflow.

Key Features:

โ€ข Interactive Branch Creation: Select the branch type (e.g., feat, fix, chore) and provide a description to generate a properly formatted branch name.
โ€ข Customizable Config: Tailor the branch types, description length, ticket ID requirements, and more through a simple configuration file.
โ€ข Efficient Workflows: Quickly create branches that follow your teamโ€™s conventions without memorizing complex naming rules.
โ€ข Simple Setup: Easily integrate with Git using a few configuration steps and start creating branches using the git cnb command.
Enter fullscreen mode Exit fullscreen mode

How It Works:

With cnb, creating a branch is as simple as:

1. Running git cnb.
2. Choosing your branch type from a set of options (e.g., feat, fix, etc.).
3. Providing a brief description.
4. The tool automatically formats your branch name according to your teamโ€™s conventions!
Enter fullscreen mode Exit fullscreen mode

Example:

โ€ข Inserted ticket id: 12345
โ€ข Selected type: feat
โ€ข Description: configure notifications
โ€ข Resulting branch: Jira-12345/feat/configure-notifications
Enter fullscreen mode Exit fullscreen mode

How to Get Started:

  1. Install cnb as a dev dependency:
npm i -D cnb
Enter fullscreen mode Exit fullscreen mode
  1. Set up a Git alias and configuration following the steps in the documentation.

Start using cnb today and bring consistency and efficiency to your Git branching workflow!

Check out the full project on GitHub or install it from npm.

Top comments (0)