The git module provides comprehensive Git repository management and automation capabilities for your application.
It offers both basic Git operations and intelligent "magic" workflows that automate common development tasks.
This module enables your application to:
- Repository Management: Perform standard Git operations (status, commit, push, pull, etc.)
- Automated Workflows: Use "magic" commands that intelligently handle common Git scenarios
- History Analysis: Examine commit history and repository state
- GitHub Integration: Work with GitHub repositories and operations
- Repository Creation: Initialize and set up new Git repositories
- Repository status checking and analysis
- Commit creation with automatic staging
- Push/pull operations with conflict detection
- Branch management and switching
- Stash operations for temporary changes
- Intelligent commit automation based on repository state
- Automatic conflict resolution strategies
- Smart push/pull decisions based on repository analysis
- Stash management during complex operations
- Commit history analysis and traversal
- Repository state validation
- GitHub API integration
- Repository creation and initialization
- Outdated branch detection
Service- Main Git service that manages repository operations- Configurable repository path
- Context-aware operations
- Comprehensive logging integration
status.go- Repository status checking and file state analysiscommit.go- Commit creation, staging, and commit countingpush.go/pull.go- Remote synchronization operationsfetch.go- Remote repository updates without mergingbranch.go- Branch management and switching operations
-
magic.go- Intelligent workflow automation- Analyzes repository state
- Performs appropriate actions automatically
- Handles complex scenarios with minimal user input
-
history.go- Commit history analysis and traversal- Configurable history depth
- Commit metadata extraction
- Timeline analysis
-
stash.go- Temporary change management- Save work-in-progress changes
- Apply stashed changes with conflict resolution
git.go- Core Git command execution and error handlingresult.go- Standardized operation result formattingcreaterepo.go- Repository initialization and setupreset.go/undo.go- Repository state restorationgh.go- GitHub-specific operations and API integration
// Create a new Git service for a repository
gitSvc := git.NewService("myrepo", "/path/to/repo")
// Check repository status
result, err := gitSvc.Status(ctx, logger)
if err != nil {
return err
}
// Commit changes
result, err = gitSvc.Commit(ctx, "Add new feature", logger)
if err != nil {
return err
}
// Push to remote
result, err = gitSvc.Push(ctx, logger)// Automatically handle common Git workflows
// This will analyze the repo state and perform appropriate actions
result, err := gitSvc.Magic(ctx, "Automated commit", false, logger)
if err != nil {
return err
}
// Dry run to see what would be done
result, err = gitSvc.Magic(ctx, "Test commit", true, logger)// Get commit history
args := &git.HistoryArgs{
Limit: 50,
// Additional filtering options
}
result, err := gitSvc.History(ctx, args, logger)The Git module integrates with the telemetry system and uses the application's logging framework. No additional configuration is required beyond ensuring Git is available in the system PATH.
- Uses
telemetry.RunProcessSimplefor Git command execution - Integrates with structured logging for operation tracking
- Respects application-level timeout and context cancellation
- Git: Must be available in system PATH
- GitHub CLI (optional): For enhanced GitHub integration
- Repository: https://github.com/kyleu/projectforge/tree/main/module/git
- License: CC0 (Public Domain)
- Author: Kyle U (kyle@kyleu.com)
- Git Documentation - Official Git documentation
- GitHub CLI Documentation - GitHub CLI reference
- Project Forge Documentation - Complete documentation