/gf

Advanced Git workflow automation tool

Primary LanguageShell

Git Flow Enhanced (gf) πŸš€

License: MIT Version Bash

A powerful Git workflow automation tool with semantic commits, Gitmoji support, automatic changelog management, and advanced features.

Author: Christian BenΓ­tez

✨ Features

  • πŸ†• Project Initialization: gf -i
  • 🌿 Branch Management:
    • Create feature branches: gf -s -f feature-name
    • Create hotfix branches: gf -s -h hotfix-name
    • Create bugfix branches: gf -s -b bugfix-name
    • Create release branches: gf -s -r release-name
  • πŸ’Ύ Smart Commits:
    • Auto-generated semantic commit messages with file count
    • Gitmoji support
    • Detailed file change tracking (new, modified, deleted, renamed)
    • English commit messages with GitLab user attribution
  • πŸ“¦ Staging Changes: gf -a or gf -a file1 file2
  • πŸ“€ Push & Create MR/PR: gf -p "commit message"
  • πŸ”€ Merge Handling: gf -m
  • πŸ—‘οΈ Branch Cleanup: gf -f
  • πŸ”„ Cross-branch MR Creation (GitLab): gf -r source target
  • πŸ“œ Advanced CHANGELOG.md Management:
    • Automatic generation and updates
    • Monthly rotation and archiving
    • Auto-cleanup of old archives (6+ months)
    • Enhanced format with user attribution

πŸš€ Installation

Linux (Ubuntu/Debian)

# Method 1: Direct download
curl -o gf https://raw.githubusercontent.com/chrisatdev/gf/main/gf
chmod +x gf
sudo mv gf /usr/local/bin/

# Method 2: Using wget
wget https://raw.githubusercontent.com/chrisatdev/gf/main/gf -O gf
chmod +x gf
sudo mv gf /usr/local/bin/

Linux (RHEL/CentOS/Fedora)

# Download and install
curl -o gf https://raw.githubusercontent.com/chrisatdev/gf/main/gf
chmod +x gf
sudo mv gf /usr/local/bin/

# Alternative: Install to user directory
mkdir -p ~/.local/bin
mv gf ~/.local/bin/
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

macOS

# Method 1: Using curl
curl -o gf https://raw.githubusercontent.com/chrisatdev/gf/main/gf
chmod +x gf
sudo mv gf /usr/local/bin/

# Method 2: Using Homebrew
brew install chrisatdev/tap/gf

# Method 3: Install to user directory
mkdir -p ~/bin
mv gf ~/bin/
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc  # or ~/.bash_profile
source ~/.zshrc  # or source ~/.bash_profile

Verify Installation

gf -h

You should see the help message with version 1.3.0.

πŸ“š Basic Usage

Initialize a new repository

gf -i

Create different types of branches

# Feature branch
gf -s -f awesome-feature

# Hotfix branch
gf -s -h critical-bug-fix

# Bugfix branch
gf -s -b login-issue

# Release branch
gf -s -r v2.1.0

Stage changes

# Stage all changes
gf -a

# Stage specific files
gf -a src/app.js package.json

Commit with enhanced messages

# Auto-generated semantic message with file count and details
gf -p

# Custom message (gitmoji added automatically)
gf -p "feat: add new payment processor"

Example auto-generated commit:

✨ feat: add new features (3 files)

Changes: 2 new, 1 modified

**New files:**
- src/components/PaymentForm.tsx
- src/utils/payment.ts

**Modified files:**
- package.json

Merge and cleanup

# Merge main into current branch
gf -m

# Delete current branch and return to main
gf -f

Create Merge Requests (GitLab)

# Create MR from current branch to main
gf -p "feat: new feature"  # Automatically opens MR

# Create MR between specific branches
gf -r feature/payment main

✨ Gitmoji Support

Automatically adds appropriate emojis based on commit type:

Type Emoji Description
feat ✨ New feature
fix πŸ› Bug fix
docs πŸ“ Documentation
style πŸ’„ Code style
refactor ♻️ Refactoring
test βœ… Testing
chore πŸ”§ Maintenance
build πŸ‘· Build system
ci βš™οΈ CI configuration
perf ⚑ Performance improvements
revert βͺ Revert changes

πŸ“œ Advanced CHANGELOG.md Management

Features:

  • Monthly Rotation: Automatically archives changelogs from previous months
  • Smart Archiving: Creates changelogs/ directory and archives with format CHANGELOG-YYYY-MM.md
  • Auto-cleanup: Removes changelog archives older than 6 months
  • Enhanced Format: Includes GitLab user attribution

Automatic Structure:

project/
β”œβ”€β”€ CHANGELOG.md              # Current month
β”œβ”€β”€ changelogs/              # Historical archives
β”‚   β”œβ”€β”€ CHANGELOG-2024-07.md # July 2024
β”‚   └── CHANGELOG-2024-08.md # August 2024
└── ...

Example CHANGELOG.md Format:

# CHANGELOG

## [Unreleased] - September 2024

### Added

- [feat] add new payment processor (3 files) by @yourusername
- [feat] implement user authentication service (5 files) by @yourusername

### Fixed

- [fix] resolve login timeout issue (2 files) by @yourusername

### Documentation

- [docs] update API documentation (1 file) by @yourusername

Monthly Rotation Behavior:

  1. Script detects if current CHANGELOG.md is from previous month
  2. Archives automatically to changelogs/CHANGELOG-YYYY-MM.md
  3. Creates new CHANGELOG.md for current month
  4. Cleans up archives older than 6 months

🎯 Workflow Examples

Feature Development Workflow

# 1. Create feature branch
gf -s -f user-profile

# 2. Make changes, then stage
gf -a

# 3. Commit and push (opens MR automatically)
gf -p

# 4. Merge main updates if needed
gf -m

# 5. When done, cleanup branch
gf -f

Hotfix Workflow

# 1. Create hotfix branch
gf -s -h critical-security-fix

# 2. Make fixes, stage and commit
gf -a
gf -p "fix: resolve security vulnerability in auth"

# 3. Cleanup
gf -f

πŸ› οΈ Requirements

  • Bash: 5.0+
  • Git: 2.20+
  • System: Linux/macOS
  • Remote: GitLab or GitHub repository
  • Optional: xdg-open (Linux) or open (macOS) for automatic MR/PR opening

πŸ”§ Configuration

The script automatically detects:

  • GitLab username from git config or remote URL
  • Repository type (GitLab/GitHub) for MR/PR creation
  • Operating system for proper date handling

Manual Git Configuration (recommended):

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

πŸ› Troubleshooting

Common Issues:

Permission denied:

chmod +x gf

Command not found:

# Ensure the binary is in your PATH
echo $PATH
which gf

Date command issues (macOS):

# Install GNU coreutils if needed
brew install coreutils

πŸ“ License

MIT License - Copyright (c) 2025 Christian BenΓ­tez

🀝 Contributing

Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.

Repository: https://github.com/chrisatdev/gf

Development:

  1. Fork the repository
  2. Create a feature branch: gf -s -f new-feature
  3. Make changes and test thoroughly
  4. Submit a pull request

πŸ”„ Version History

  • v1.3.0: Monthly changelog rotation, enhanced commit messages, auto-cleanup
  • v1.2.0: Improved changelog format, GitLab user attribution
  • v1.1.2: Enhanced semantic commits and Gitmoji support
  • v1.0.0: Initial release with basic Git workflow automation

Made with ❀️ by Christian Benítez