Skip to main content

branch-util

branch-util is a Python package for branch-related CLI tools. The first available tool is create-branch, which creates git branches with a naming schema.

Package scope

  • Current tool: create-branch
  • Planned scope: additional branch-related CLI tools (for example branch-switch and branch-clean)

Features

  • Interactive selection of branch type and source branch
  • Hierarchical source branch selection by path levels
  • Optional configuration (JSON or YAML)
  • Configurable branch types (default: feature, bugfix, hotfix, release)
  • Configurable branch schema (default: <type>/<source>/<name>)
  • Local branches are hidden by default in the source selection
  • Checks local and remote branches before creating
  • Creates and checks out the new branch, optionally pushes to a remote

Installation

Make sure you have Python 3.7+ installed, then install the package:

pip install branch-util

If you want YAML configuration support:

pip install branch-util[yaml]

Usage

Command-line interface

create-branch [repo_path] [--config config.json]

Run as module

# Windows
python -m create_branch [repo_path] [--config config.json]

# Linux
python3 -m create_branch [repo_path] [--config config.json]

Run the script directly

# Windows
python create_branch\cli.py [repo_path] [--config config.json]

# Linux
python3 create_branch/cli.py [repo_path] [--config config.json]

Arguments

  • repo_path: Path to the git repository (optional, defaults to current directory)
  • --config, -c: Path to configuration file (JSON or YAML)
  • --log-level: Logging level for file output (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  • --log-file, --log-path: Optional path to log file (default: create-branch.log)
  • --version, -v: Show version information and exit

Configuration

Example JSON:

{
  "branch_types": ["feature", "bugfix", "hotfix", "release"],
  "remote": "origin",
  "branch_schema": "<type>/<source>/<name>",
  "show_local_branches": false
}

Example YAML:

branch_types:
  - feature
  - bugfix
  - hotfix
  - release
remote: origin
branch_schema: "<type>/<source>/<name>"
show_local_branches: false

If no configuration is provided, the default branch types are used.

Local branch visibility

By default, local branches are hidden in the source selection. Set show_local_branches to true to include them.

Schema placeholders

Supported placeholders in the branch schema:

  • <type> or {type}
  • <source> or {source}
  • <name> or {name}

Behavior

  1. The tool runs git fetch --all --prune.
  2. You select the branch type.
  3. You select the source branch level by level:
    • The current level shows branches without deeper path segments and first-level folders.
    • Folders are marked with a trailing /.
    • With one remote, navigation starts at the remote branch path (for example main, feature/).
    • With multiple remotes, remote names are shown as top-level folders (for example origin/, upstream/).
    • If local branches are shown, local entries appear before remote entries.
    • Selecting a folder opens the next level, and ../ navigates one level up.
  4. You enter the new branch name.
  5. The tool validates the full branch name and checks for existing branches.
  6. The branch is created. You can choose whether to switch to it.
  7. If a remote exists, it tries to push.

Logging

  • Log entries are written to a file with timestamp (YYYY-MM-DD HH:MM:SS).
  • Console output is shown from level INFO and higher (INFO, WARNING, ERROR, CRITICAL).

Trademarks

Git and the Git logo are either registered trademarks or trademarks of Software Freedom Conservancy, Inc., corporate home of the Git Project, in the United States and/or other countries. This project is not affiliated with or endorsed by them.

License

This project is open source and available under the MIT License.

Copyright (c) 2026 Janosch Meyer (janosch.code@proton.me)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note: This project was created with the assistance of artificial intelligence.

Release files for branch-util 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for branch-util 0.1.0
File Size Uploaded
branch_util-0.1.0.tar.gz 13.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for branch-util 0.1.0
File Interpreter ABI Platform
branch_util-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.9 kB

Release files / branch_util-0.1.0.tar.gz

Download URL branch_util-0.1.0.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
60e175b3a0b5ba9a43ae5dcdb6adeb4b018671c260e4166d4298fd314062e432
BLAKE2b-256 checksum
How to use checksums
09335719400f06a0058ba8ebc94ce0892c01b3c9cb2756c98bb4eea42af7e83f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / branch_util-0.1.0-py3-none-any.whl

Download URL branch_util-0.1.0-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d9d1255e0e80336ee4a4ca3f5a846f75c4f1d1f440dfe3894bf4988a6a5bdc6
BLAKE2b-256 checksum
How to use checksums
9585cf5754cad02461d0cc9a64ff3dcc593dab6c57ced4b53cc860185d3e15e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page