Skip to content

bashhack/gitbak

Repository files navigation

gitbak logo

Tests Coverage Go Reference Go Report Card CodeRabbit Reviews

gitbak - Automatic Commit Safety Net

Automated checkpoint commits during programming sessions.

🎯 Purpose

When programming (with humans or AI assistants alike), the conversation and code changes can move quickly.

gitbak provides safety by:

  • Allowing you to focus on coding without worrying about losing changes
  • Creating automatic commits at regular intervals
  • Making a clean history of your pairing session progress
  • Providing recovery points if something goes wrong

This helps you avoid common pitfalls like the:

  • "I forgot to commit" panic
  • "I thought that git command did something else" confusion
  • "I lost my changes" frustration
  • "I wish we could go back to that thread we pulled on thirty minutes ago" regret

🌟 Features

  • Automatic Commits - Set and forget checkpoints at regular intervals
  • Branch Management - Creates a dedicated branch or uses current one
  • Session Continuation - Resume sessions with sequential commit numbering
  • Robust Error Handling - Smart retry logic and signal handling
  • Platform Support - Available for macOS and Linux systems

📦 Installation

# Option 1: Install with Homebrew (macOS and Linux)
brew install bashhack/gitbak/gitbak
# Note: Homebrew automatically adds gitbak to your PATH, so it's ready to use immediately

# Option 2: Install using Go (requires Go 1.24+)
go install github.com/bashhack/gitbak/cmd/gitbak@latest
# Note: Ensure your Go bin directory (typically $HOME/go/bin) is in your PATH
# You can add this to your shell profile (~/.bashrc, ~/.zshrc, etc.):
# export PATH=$PATH:$HOME/go/bin

# Option 3: Download pre-built binary
# Visit: https://github.com/bashhack/gitbak/releases

⚠️ Note: While a shell script implementation exists in the repository for historical reasons, it is unsupported and not recommended for use. The Go version provides better reliability, performance, and ongoing support.

🚀 Quick Start

# Navigate to your Git repository
cd /path/to/your/repo

# Start gitbak with default settings (5-minute commits)
gitbak

# Press Ctrl+C to stop when finished

💡 Best Practice: Manual + Automatic Workflow

A powerful workflow pattern with gitbak is combining automatic safety checkpoints with manual milestone commits:

# Start gitbak on your current branch
gitbak -no-branch

# While gitbak creates automatic commits, you can still:
git add <files>
git commit -m "Implement login feature"

# gitbak continues creating safety checkpoints while you create
# meaningful commits for important milestones

This gives you both a detailed safety net AND a clean, meaningful commit history - the best of both worlds!

💪 See Comparison with Alternatives for why this approach is superior to IDE auto-save features.

🔄 After Your Session

# Squash all checkpoint commits into one
git checkout main
git merge --squash gitbak-TIMESTAMP 
git commit -m "Complete feature implementation"

⚙️ Configuration

# Custom interval (2 minutes)
gitbak -interval 2

# Custom branch name
gitbak -branch "feature-work-backup"

# Continue a previous session
gitbak -continue

# Use the current branch
gitbak -no-branch

# Full options list
gitbak -help

📚 Documentation

📋 Implementation Details

Feature Details
Dependencies Git only
Platform macOS and Linux
Configuration Command-line flags and environment variables
Resource usage ~5-6 MB

🧑‍💻 Development

# Clone the repository
git clone https://github.com/bashhack/gitbak.git
cd gitbak

# Run tests
make test

# Run tests in Ubuntu container (simulates GitHub Actions environment)
./scripts/test-all.sh

# Test specific packages in Ubuntu container
./scripts/ubuntu-test.sh ./pkg/lock/...

# Build for development
make build

# Install locally
make install

See the scripts README for more information on testing in Ubuntu containers to catch platform-specific issues before they reach CI.

📄 License

MIT

About

Automatic Commit Safety Net

Resources

License

Stars

Watchers

Forks

Packages

No packages published