Version: v1.2.3 | Status: Active | Last Updated: March 2026
The git_operations module provides comprehensive Git workflow automation, repository management, and version control operations. It exposes both CLI and programmatic APIs for interacting with Git repositories.
from codomyrmex.git_operations import GitRepository, clone_repository, init_repository
# Clone a repository
repo = clone_repository(
url="https://github.com/example/repo.git",
path="/path/to/local",
branch="main"
)
# Initialize a new repository
repo = init_repository(path="/path/to/new/repo")
# Open existing repository
repo = GitRepository("/path/to/existing/repo")from codomyrmex.git_operations import commit, stage_files, get_diff
# Stage files
stage_files(repo, ["file1.py", "file2.py"])
# Create commit
commit_hash = commit(
repo,
message="Add new feature",
author="Developer <dev@example.com>"
)
# Get diff
diff = get_diff(repo, from_ref="HEAD~1", to_ref="HEAD")from codomyrmex.git_operations import (
create_branch,
checkout_branch,
merge_branch,
list_branches,
delete_branch
)
# Create and checkout branch
create_branch(repo, "feature/new-feature")
checkout_branch(repo, "feature/new-feature")
# List branches
branches = list_branches(repo, remote=True)
# Merge branch
merge_branch(repo, source="feature/new-feature", target="main")from codomyrmex.git_operations import push, pull, fetch, add_remote
# Add remote
add_remote(repo, name="upstream", url="https://github.com/upstream/repo.git")
# Fetch updates
fetch(repo, remote="origin")
# Pull changes
pull(repo, remote="origin", branch="main")
# Push changes
push(repo, remote="origin", branch="feature-branch")from codomyrmex.exceptions import GitOperationError, RepositoryError
try:
repo = clone_repository(url, path)
except GitOperationError as e:
print(f"Git command failed: {e.context.get('git_command')}")
except RepositoryError as e:
print(f"Repository error: {e}")The module respects Git configuration from:
- Repository-level
.git/config - User-level
~/.gitconfig - System-level
/etc/gitconfig - Environment variables (
GIT_AUTHOR_NAME,GIT_AUTHOR_EMAIL, etc.)
# Clone repository
codomyrmex git clone https://github.com/example/repo.git
# Show status
codomyrmex git status
# Create branch
codomyrmex git branch feature/new-feature
# Commit changes
codomyrmex git commit -m "Add feature"logging_monitoring- All operations are loggedexceptions- Uses unified exception hierarchyconfig_management- Git configuration integrationsecurity- Credential management
- Human Documentation: README.md
- Technical Documentation: AGENTS.md
- Functional Specification: SPEC.md
- Parent Directory: codomyrmex
- Repository Root: ../../../README.md