Documentation
ยถ
Overview ยถ
Package gitbak is an automatic commit safety net
gitbak automatically commits changes to git at regular intervals, providing a safety net for programming sessions. It's especially valuable for pair programming, long coding sessions, or exploratory coding where you want to focus on the work rather than remembering to commit. It runs as a background process that monitors your repository and creates sequential, numbered commits.
While gitbak creates automatic checkpoint commits, you can still make your own meaningful manual commits at important milestones. This powerful combination gives you both a detailed safety net AND a clean, meaningful commit history - the best of both worlds.
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
Key Features ยถ
- Automatic Commits: Creates commits at regular intervals (default: 5 minutes)
- Branch Management: Creates a dedicated branch or uses the current one
- Session Continuation: Resume sessions with sequential numbering
- Robust Error Handling: Smart retry logic and graceful signal handling
Documentation Structure ยถ
The gitbak documentation is organized into several sections:
- Command Documentation: https://pkg.go.dev/github.com/bashhack/gitbak/go/cmd/gitbak
- Usage & Configuration: https://github.com/bashhack/gitbak/blob/main/go/docs/USAGE_AND_CONFIGURATION.md
- After Session Guide: https://github.com/bashhack/gitbak/blob/main/go/docs/AFTER_SESSION.md
- IDE Integration: https://github.com/bashhack/gitbak/blob/main/go/docs/IDE_INTEGRATION.md
- Comparison with Alternatives: https://github.com/bashhack/gitbak/blob/main/go/docs/COMPARISON.md
Module Structure ยถ
The module is organized into these packages:
- cmd/gitbak: Command-line interface
- internal/git: Git operations and commit logic
- internal/config: Configuration and flag parsing
- internal/lock: File-based locking mechanism
- internal/logger: Logging facilities
- internal/errors: Error handling utilities
- internal/constants: ASCII art and fixed values
Common Configuration Options ยถ
# Run with 2-minute intervals gitbak -interval 2 # Use a custom branch name gitbak -branch "my-backup-branch" # Continue a previous session gitbak -continue # Use the current branch instead of creating a new one gitbak -no-branch
After Your Session ยถ
When your session is complete, you can squash all checkpoint commits into one:
# Switch back to your main branch git checkout main # Combine all gitbak commits into a single change set git merge --squash gitbak-TIMESTAMP # Create a single, meaningful commit with all changes git commit -m "Complete feature implementation"
Design Philosophy ยถ
gitbak is designed with the following principles in mind:
- Simple Usage: Provide a straightforward interface for common use cases
- Robustness: Handle errors gracefully and recover when possible
- Non-Intrusion: Stay out of the way of the developer's primary workflow
- Safety: Avoid data loss and never push to remote repositories
- Transparency: Make it clear what operations are being performed
Platform Support ยถ
gitbak is available for:
- macOS (Intel and Apple Silicon)
- Linux (x86_64, ARM64)
- Unix-like systems with a POSIX-compliant shell
Implementation Notes ยถ
gitbak uses the command-line Git executable rather than a Go Git library to ensure compatibility with all Git features and repository configurations. Commands are executed through an abstracted interface that can be replaced for testing.
The application handles signals (such as SIGINT, SIGTERM, and SIGHUP) to ensure proper cleanup and summary display even when terminated unexpectedly.
Directories
ยถ
Path | Synopsis |
---|---|
cmd
|
|
gitbak
command
Package main implements gitbak, an automatic commit safety net
|
Package main implements gitbak, an automatic commit safety net |
internal
|
|
config
Package config provides configuration handling for the gitbak application.
|
Package config provides configuration handling for the gitbak application. |
constants
Package constants provides application-wide constant values for the gitbak application.
|
Package constants provides application-wide constant values for the gitbak application. |
errors
Package errors provides error handling utilities for the gitbak application.
|
Package errors provides error handling utilities for the gitbak application. |
git
Package git provides Git operations for the gitbak application.
|
Package git provides Git operations for the gitbak application. |
lock
Package lock provides file-based locking for the gitbak application.
|
Package lock provides file-based locking for the gitbak application. |
logger
Package logger provides logging facilities for the gitbak application.
|
Package logger provides logging facilities for the gitbak application. |