npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@div0ky/branchflow

v1.3.0

Published

CLI tool for modified Git-Flow with a linear history

Downloads

883

Readme

BranchFlow CLI

A powerful command-line interface for streamlined Git workflow management. BranchFlow enforces consistent branching strategies and automates common Git operations while maintaining a clean repository state.

Version License

Features

  • 🌿 Standardized branch management (feature, fix, hotfix)
  • 🔄 Automated branch creation and merging workflows
  • 💾 Single-commit workflow with automatic save functionality
  • 🔄 Intelligent stashing of changes during branch operations
  • 🛡️ Branch protection system with safe deletion mechanisms
  • 🚀 Streamlined release process with safety checks
  • 🎭 Flexible staging environment for pre-production testing
  • 📋 Branch status overview with protection indicators
  • 🎯 Git-flow inspired workflow enforcement
  • 🎨 Beautiful CLI with colorful interface and interactive prompts
  • 🔀 Interactive branch switching with automatic stash handling
  • 🌍 Sophisticated remote branch synchronization

Prerequisites

  • Node.js 14 or higher
  • Git installed and configured
  • Active Git repository (or BranchFlow can initialize one for you)

Installation

npm install -g @div0ky/branchflow

Quick Start

  1. Navigate to your Git repository:
cd your-project
  1. Initialize BranchFlow:
bf init

During initialization, BranchFlow will:

  • Verify or create a Git repository if needed
  • Detect or prompt for your main branch
  • Create a development (dev) branch if it doesn't exist
  • Set up the necessary configuration
  • Attempt to set up remote tracking (if a remote exists)

Branch Types and Naming Convention

BranchFlow enforces consistent branch naming with the following prefixes:

  • Features: feat/ or feature/ (both supported)
  • Bug fixes: fix/
  • Hot fixes: hotfix/

Core Concepts

Single-Commit Workflow

BranchFlow implements a clean single-commit workflow:

  • Each branch starts with an empty initial commit (message: ".")
  • All changes are saved by amending this single commit
  • The final commit message is set when finishing the branch
  • Force pushing is handled automatically when needed
  • This approach keeps branch history clean and focused

Auto-stashing

BranchFlow automatically handles uncommitted changes during branch operations:

  • Changes are stashed when switching branches
  • Stashes are automatically reapplied after the operation
  • Stash conflicts are detected and reported
  • Recovery mechanisms for failed stash operations
  • Stashed changes are committed automatically when creating new branches

Remote Synchronization

BranchFlow handles remote operations intelligently:

  • Detects existence of remote branches
  • Uses appropriate push strategies (normal vs force)
  • Creates tracking relationships for new branches
  • Handles remote branch cleanup during finish/abandon
  • Provides fallbacks for remote operation failures

Command Reference

Basic Commands

# Branch Creation
bf feature new my-feature  # Creates feat/my-feature
bf fix new bug-123        # Creates fix/bug-123
bf hotfix new critical    # Creates hotfix/critical

# Save Changes
bf save                   # Stages, amends, and pushes changes

# Switch Branches
bf checkout              # Interactive branch switching
bf co                    # Shorthand for checkout

# Finish Branches
bf feature finish        # Select and finish a feature branch
bf fix finish            # Select and finish a fix branch
bf hotfix finish         # Select and finish a hotfix branch
bf finish                # Finish current branch

# Stage Changes
bf stage                 # Stage everything from dev
bf stage feature         # Select a feature branch to stage
bf stage fix             # Select a fix branch to stage
bf stage hotfix          # Select a hotfix branch to stage

# Release to Main
bf release               # Merge dev into main

# Branch Management
bf list                  # List all branches with status
bf abandon               # Safely abandon current branch
bf protect <name>        # Protect a branch
bf unprotect <name>     # Remove branch protection

# Branch Synchronization
bf sync                   # Rebase current branch from dev

Command Details

Branch Creation (new)

bf <type> new <name>
  • Creates branch from latest dev
  • Generates initial empty commit
  • Stashes and reapplies any current changes
  • Sets up remote tracking
  • Handles existing branch scenarios

Save Changes (save)

bf save
  • Stages all current changes
  • Amends the branch's single commit
  • Force pushes to remote if needed
  • Creates remote branch if it doesn't exist
  • Blocked on protected branches
  • Notifies if branch is behind dev (except for hotfix branches)

Branch Switching (checkout/co)

bf checkout  # or bf co
  • Shows interactive branch list
  • Excludes current branch from options
  • Automatically stashes changes
  • Reapplies changes after switch
  • Handles stash conflicts

Finishing Branches (finish)

bf <type> finish  # or just bf finish
  • Interactive branch selection (if type specified)
  • Uses current branch (if no type specified)
  • Prompts for final commit message
  • Stages and commits any changes
  • Updates target branch
  • Handles remote cleanup
  • Special hotfix handling (merges to both dev and main)

Staging (stage)

bf stage [type]
  • Creates staging branch if needed
  • Interactive branch selection
  • Updates and rebases staging
  • Proper merge sequence
  • Returns to original branch
  • Options:
    • No type: Stages dev
    • With type: Select specific branch

Release Command (release)

bf release
  • Updates both branches
  • Performs safety checks
  • Requires confirmation
  • Maintains clean history
  • Handles remote synchronization

Protection Commands

bf protect <branch-name>    # Add protection
bf unprotect <branch-name>  # Remove protection
  • Prevents deletion
  • Blocks automated merges
  • Prevents abandonment
  • Stores status in config

Branch Listing (list)

bf list
  • Shows all branches
  • Indicates current branch
  • Shows protection status
  • Shows remote status
  • Color-coded output

Branch Abandonment (abandon)

bf abandon
  • Discards all changes
  • Deletes local and remote
  • Blocked for protected branches
  • Requires confirmation
  • Includes cleanup operations

Branch Synchronization (sync)

bf sync
  • Rebases current branch from dev
  • Not available for hotfix branches
  • Updates local branch with latest dev changes
  • Helps prevent conflicts during finish
  • Handles remote synchronization

Configuration

BranchFlow stores its configuration in .branchflow.json:

{
  "initialized": true,
  "mainBranch": "main",
  "protectedBranches": ["main", "dev", "staging"],
  "initDate": "2024-01-01T00:00:00.000Z"
}

Configuration details:

  • initialized: Indicates BranchFlow setup status
  • mainBranch: Primary production branch name
  • protectedBranches: List of protected branch names
  • initDate: Installation timestamp

Error Handling

BranchFlow provides robust error handling for:

Operation Failures

  • Remote connectivity issues
  • Permission problems
  • Merge conflicts
  • Stash conflicts
  • Branch protection violations

Recovery Mechanisms

  • Stash recovery during errors
  • Force delete fallbacks
  • Remote operation retries
  • Automatic conflict detection
  • Clear error reporting

Safety Features

  • Confirmation prompts for destructive actions
  • Branch protection system
  • Safe branch deletion with checks
  • Automatic update checks
  • Force push protection
  • Stash management
  • Remote operation safeguards

Updating BranchFlow

Automatic Update Detection

  • Checks for updates on command execution
  • Shows available version information
  • Provides update instructions

Update Command

bf update
  • Checks for latest version
  • Downloads and installs updates
  • Provides feedback
  • Shows manual steps if needed

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (bf feature new amazing-feature)
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

Version update process:

  1. Update version in package.json
  2. CLI version auto-matches package.json
  3. README badge auto-updates with npm version

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter issues:

  1. Check error messages
  2. Verify Git repository state
  3. Check branch protection settings
  4. Review configuration file
  5. File an issue on GitHub

Workflow Example

Here's a typical workflow using BranchFlow:

  1. Create feature branch:

    bf feature new user-auth
  2. Make and save changes:

    # Edit files
    bf save
    # More changes
    bf save
  3. Switch branches if needed:

    bf checkout  # Changes auto-stashed
    # Do other work
    bf checkout  # Return to feature
  4. Stage for testing:

    bf stage feature  # Select your branch
  5. Finish feature:

    bf finish  # On feature branch
    # or
    bf feature finish  # From anywhere

Built with ❤️ by developers, for developers who love clean Git workflows.