Skip to main content

Branch utility package. Currently includes the create-branch CLI tool (Interactive tool to create git branches with a naming schema).

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

branch_util-0.1.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

branch_util-0.1.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file branch_util-0.1.0.tar.gz.

File metadata

  • Download URL: branch_util-0.1.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for branch_util-0.1.0.tar.gz
Algorithm Hash digest
SHA256 60e175b3a0b5ba9a43ae5dcdb6adeb4b018671c260e4166d4298fd314062e432
MD5 532856521579a6cb83590e7cecb767e4
BLAKE2b-256 09335719400f06a0058ba8ebc94ce0892c01b3c9cb2756c98bb4eea42af7e83f

See more details on using hashes here.

File details

Details for the file branch_util-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: branch_util-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for branch_util-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d9d1255e0e80336ee4a4ca3f5a846f75c4f1d1f440dfe3894bf4988a6a5bdc6
MD5 31445d7b81735e759c53a121ba0d70ef
BLAKE2b-256 9585cf5754cad02461d0cc9a64ff3dcc593dab6c57ced4b53cc860185d3e15e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page