Skip to content

Git-First Versioned Storage

Git-First Versioned Storage: Signed Commits, git-crypt/LFS

Section titled “Git-First Versioned Storage: Signed Commits, git-crypt/LFS”

Modern configuration management systems require robust version control, cryptographic authenticity, and integrity verification to maintain audit trails and ensure security compliance. Git-First Versioned Storage provides a repository-based backend that treats all configuration changes as version-controlled commits, with optional GPG signing for authenticity and Git LFS for efficient large file handling.

This addresses the challenge of traditional database or filesystem storage approaches that lack built-in version control, cryptographic verification, and comprehensive change auditing. Organizations can leverage Git-based storage to establish immutable audit trails, implement non-repudiation for configuration changes, and integrate configuration management into standard DevOps workflows.

The Git-First approach provides:

  • Git-style repository backend - Full version control with branching, merging, and history
  • Optional signed commits - GPG/PGP signatures for authentication and non-repudiation
  • Git LFS support - Efficient handling of large configuration files and binary assets
  • Cryptographic integrity - Tamper-evident storage with hash verification
  • Transparent encryption - git-crypt for protecting sensitive configuration data

The Git-based storage layer implements a standard Git repository structure optimized for configuration management:

config-repo/
├── .git/
├── configs/
│ ├── application.yml
│ ├── database.yml
│ └── services/
├── .gitattributes (LFS configuration)
└── .git-crypt/ (optional encryption)

All configuration changes can be tracked through GPG-signed commits, providing critical security assurances:

  • Authenticity - Cryptographically verify who made each change
  • Non-repudiation - Commit creators cannot deny their changes
  • Integrity - Detect any tampering with commit history
  • Compliance - Meet audit requirements for change tracking

Signed commits create an immutable chain of custody for all configuration modifications. Each commit signature can be verified against the signer’s public key, ensuring changes originated from authorized personnel.

Configuration Example:

Terminal window
git config commit.gpgsign true
git config user.signingkey <GPG_KEY_ID>

For large configuration files, binary assets, or certificates, Git LFS provides efficient storage:

  • Pointer-based storage - Git stores small pointer files while actual content lives separately
  • Reduced repository size - Large files don’t bloat the repository history
  • Improved performance - Faster clone and fetch operations
  • Bandwidth optimization - Download large files only when needed

Git LFS is essential when managing configuration files that exceed several megabytes, such as firmware images, certificate stores, or comprehensive device backups.

Configuration example (.gitattributes):

*.bin filter=lfs diff=lfs merge=lfs -text
*.cert filter=lfs diff=lfs merge=lfs -text
*.p12 filter=lfs diff=lfs merge=lfs -text

Transparent encryption for sensitive configuration data at rest:

  • Automatic encryption - Files encrypt before committing to repository
  • Seamless decryption - Authorized users decrypt automatically on checkout
  • Selective encryption - Encrypt only sensitive files, leave others readable
  • Key-based access - Control decryption through GPG key management

git-crypt integrates seamlessly with standard Git operations. Users with proper GPG keys automatically decrypt files during checkout, while unauthorized users see only encrypted content.

Cryptographic signatures ensure change accountability: Every configuration modification carries a verifiable signature identifying the author. This meets regulatory requirements for change management and creates legally defensible audit trails.

Encrypted storage protects sensitive configurations: Credentials, API keys, and proprietary network topologies remain encrypted in the repository, protecting against unauthorized access even if repository storage is compromised.

Complete audit trail with verifiable history: Git’s immutable commit history combined with signature verification provides tamper-evident logging of all configuration changes, essential for security audits and compliance reporting.

Granular access control through GPG key management: Organizations control who can commit signed changes and decrypt sensitive data by managing GPG key distribution, enabling precise access policies.

Full history of all configuration changes: Every modification is preserved with complete context including author, timestamp, and rationale. This enables comprehensive change analysis and root cause investigation.

Branching and merging for environment-specific configs: Maintain separate branches for production, staging, and development configurations while selectively merging changes between environments as needed.

Instant rollback capability to any previous state: Configuration errors can be immediately reverted by checking out previous commits, eliminating the need for manual restoration or backup recovery.

Advanced diff tools for configuration comparison: Leverage Git’s powerful diff capabilities to compare configurations across time periods, branches, or environments, identifying exactly what changed and when.

Collaboration through standard Git workflows: Teams already familiar with Git for code management can apply the same pull request, code review, and approval processes to configuration changes.

Code review processes for configuration changes: Implement peer review requirements before configuration modifications reach production, reducing errors and knowledge-sharing across teams.

CI/CD integration for automated validation: Integrate configuration repositories with continuous integration pipelines to automatically validate syntax, check policy compliance, and run tests before accepting changes.

Distributed disaster recovery: Every clone of the Git repository serves as a complete backup. Multiple team members and systems maintain full copies of configuration history, providing inherent disaster recovery capabilities.

Implementing Git-First Versioned Storage requires careful planning and phased deployment to ensure smooth transition and maintain operational continuity.

Establish the Git repository structure and configure essential features before importing any configuration data.

Step 1: Create repository structure

Terminal window
# Create new repository
git init config-repo
cd config-repo
# Create directory structure
mkdir -p configs/services
mkdir -p templates
mkdir -p policies
# Initialize README
cat > README.md << EOF
# Configuration Repository
Git-based storage for system configurations with signed commits and LFS support.
## Structure
- configs/: Active configuration files
- templates/: Configuration templates
- policies/: Compliance and validation policies
EOF
git add README.md
git commit -m "Initial repository structure"

Step 2: Configure Git LFS

Terminal window
# Install Git LFS (if not already installed)
# Ubuntu/Debian:
sudo apt-get install git-lfs
# CentOS/RHEL/Rocky/AlmaLinux:
sudo yum install git-lfs
# Initialize LFS in repository
git lfs install
# Configure LFS tracking
cat > .gitattributes << EOF
*.bin filter=lfs diff=lfs merge=lfs -text
*.cert filter=lfs diff=lfs merge=lfs -text
*.p12 filter=lfs diff=lfs merge=lfs -text
*.firmware filter=lfs diff=lfs merge=lfs -text
*.img filter=lfs diff=lfs merge=lfs -text
EOF
git add .gitattributes
git commit -m "Configure Git LFS for binary files"

Step 3: Configure signed commits

Terminal window
# Generate GPG key if needed
gpg --full-generate-key
# List GPG keys to find key ID
gpg --list-secret-keys --keyid-format=long
# Configure Git to use GPG key
git config user.signingkey <YOUR_GPG_KEY_ID>
git config commit.gpgsign true
# Test signed commit
git commit --allow-empty -m "Test signed commit"
git verify-commit HEAD

Step 4: Set up git-crypt (optional)

Terminal window
# Install git-crypt
# Ubuntu/Debian:
sudo apt-get install git-crypt
# CentOS/RHEL/Rocky/AlmaLinux:
sudo yum install git-crypt
# Initialize git-crypt in repository
git-crypt init
# Export encryption key for backup
git-crypt export-key ../config-repo-key
# Configure which files to encrypt
cat > .gitattributes << EOF
# Existing LFS configuration...
*.key filter=git-crypt diff=git-crypt
*.secret filter=git-crypt diff=git-crypt
*_credentials.* filter=git-crypt diff=git-crypt
secrets/** filter=git-crypt diff=git-crypt
EOF
git add .gitattributes
git commit -m "Configure git-crypt for sensitive files"

Store GPG keys securely: GPG private keys must never be stored in plain text or committed to repositories. Use hardware security modules (HSMs), key management services (KMS), or encrypted vaults for production keys.

Implement key rotation policies: Establish regular key rotation schedules (annually or bi-annually) to limit exposure window if keys are compromised. Document rotation procedures and test them regularly.

Maintain revocation procedures: Prepare key revocation processes for compromised or lost keys. Publish revocation certificates to key servers and update all systems to reject signatures from revoked keys.

Document key recovery process: Create secure procedures for key recovery when personnel leave or keys are lost. Store key backups in multiple secure locations with appropriate access controls.

Limit repository write access: Grant commit permissions only to authorized personnel. Implement role-based access control where junior staff can view configurations but only senior engineers can modify them.

Enforce signed commits via hooks: Use Git hooks to reject unsigned commits automatically. This prevents accidental or malicious unsigned modifications from entering the repository. Implement branch protection rules: Configure branch protection to require pull requests, code reviews, and passing tests before merging changes to main branches. This creates approval gates for critical configurations.

Audit access logs regularly: Review repository access logs monthly to identify unusual patterns, unauthorized access attempts, or suspicious activities. Integrate with security information and event management (SIEM) systems.

Validate signatures on retrieval: Always verify commit signatures when reading configurations. Treat unsigned or invalidly-signed commits as security incidents requiring investigation.

Verify LFS object checksums: Confirm LFS objects match expected checksums after download. This detects corruption or tampering during transmission or storage.

Monitor for unauthorized changes: Implement automated monitoring that alerts on unexpected commits, signature verification failures, or modifications outside approved change windows.

Alert on signature failures: Configure immediate notifications when signature verification fails. These events may indicate compromise, key issues, or attacks and require urgent investigation.

Git 2.x or higher: Modern Git features including LFS, improved signing, and performance enhancements require Git 2.0+. Git 2.30+ recommended for best compatibility.

GPG/GnuPG for signing: GPG 2.2+ required for commit signing. Ensure GPG is properly configured with key generation, signing, and verification capabilities.

Git LFS extension: Install Git LFS client on all systems that will interact with the repository. Version 2.0+ recommended for improved performance and reliability.

git-crypt (optional): If using transparent encryption, install git-crypt 0.6+ on all authorized systems. Verify compatibility with your Git version before deployment.

Repository storage backend: Dedicated filesystem or object storage for Git repositories. Allocate sufficient space for repository growth including history and LFS objects.

Signature verification service: Automated service that validates commit signatures on read operations. Should integrate with your GPG keyring management infrastructure.

LFS object store: Separate storage tier for large files tracked by LFS. Can use local filesystem, network storage, or cloud object storage (S3, Azure Blob, etc.).

Encryption key management: Secure storage and distribution system for git-crypt keys and GPG private keys. Should support key rotation, backup, and access auditing.

Comprehensive monitoring ensures the Git-based storage system operates reliably and securely:

Commit signature validation rate: Track percentage of commits successfully verified. Rates below 100% indicate signing issues, key problems, or potential security concerns requiring investigation.

LFS object retrieval performance: Monitor download times for LFS objects. Degrading performance may indicate network issues, storage problems, or capacity constraints requiring infrastructure scaling.

Repository size growth: Track repository size over time to project storage needs and identify opportunities for optimization. Unexpectedly rapid growth may indicate LFS misconfiguration or large files committed incorrectly.

Failed signature attempts: Alert on any signature verification failures. These may indicate compromised keys, system clock skew, or malicious activity requiring immediate security review.

git-crypt unlock failures: Monitor git-crypt unlock operations for failures. Problems may indicate key distribution issues, permission problems, or attempted unauthorized access.

Key rotation and renewal: Rotate GPG keys according to organizational policy (typically annually). Update all systems with new keys, revoke old keys, and verify signature chain integrity.

LFS object cleanup: Periodically run git lfs prune to remove unreferenced LFS objects. This recovers storage space from deleted or replaced files while preserving objects referenced in Git history.

Repository maintenance: Execute git gc and git prune regularly to optimize repository performance. Large repositories benefit from monthly maintenance; smaller ones can run quarterly.

Backup verification: Test repository backups monthly by restoring to separate systems and verifying contents. Confirm LFS objects, encrypted files, and signature verification all work correctly from backups.

  • Git Documentation - Signing Commits: Comprehensive guide to GPG commit signing configuration and verification
  • Git LFS Documentation: Official documentation for Large File Storage setup and operation
  • git-crypt Repository: Project documentation for transparent Git encryption
  • GPG Best Practices: Security guidelines for key generation, storage, and management
Terminal window
# Verify commit signature
git verify-commit <commit-hash>
# View commit signature details
git log --show-signature
# List LFS tracked files
git lfs ls-files
# Check LFS status
git lfs status
# Manually unlock git-crypt
git-crypt unlock /path/to/key
# Lock git-crypt (encrypt files)
git-crypt lock
# Repository maintenance
git gc --aggressive
git prune
git lfs prune

Pre-commit hook to require signing:

.git/hooks/pre-commit
#!/bin/bash
# Check if commit is signed
if ! git var GIT_COMMITTER_IDENT > /dev/null 2>&1; then
echo "ERROR: No GPG signing key configured"
echo "Run: git config user.signingkey <KEY_ID>"
exit 1
fi
if ! git config commit.gpgsign | grep -q true; then
echo "ERROR: Commit signing not enabled"
echo "Run: git config commit.gpgsign true"
exit 1
fi

Server-side hook to reject unsigned commits:

#!/bin/bash
# hooks/update (server-side)
zero_commit="0000000000000000000000000000000000000000"
while read oldrev newrev refname; do
if [ "$newrev" = "$zero_commit" ]; then
continue
fi
# Check all new commits
for commit in $(git rev-list $oldrev..$newrev); do
if ! git verify-commit $commit 2>/dev/null; then
echo "ERROR: Commit $commit is not signed or has invalid signature"
exit 1
fi
done
done
exit 0

Git-First Versioned Storage transforms configuration management by applying proven version control practices to system configurations. By leveraging Git’s distributed architecture, cryptographic signing for authenticity, LFS for efficient large file handling, and optional encryption for sensitive data, organizations establish robust audit trails while maintaining operational flexibility.

Key benefits of this approach include:

  • Cryptographic authenticity - Every change is cryptographically signed, creating non-repudiable audit trails that meet compliance requirements
  • Comprehensive history - Full version history with branching, merging, and instant rollback capabilities
  • Distributed resilience - Every clone serves as a complete backup, providing inherent disaster recovery
  • Developer-friendly workflows - Leverage familiar Git operations, pull requests, and code review processes
  • Efficient large file handling - LFS prevents repository bloat while maintaining fast clone and fetch operations
  • Transparent encryption - Protect sensitive configurations at rest without impacting standard Git operations

Implementation requires careful attention to key management, access control, and integration with existing systems. Organizations should phase deployment through development environments first, validate all security features thoroughly, and establish monitoring before production rollout.

For systems managing critical network infrastructure, financial data, or sensitive configurations, Git-First Versioned Storage provides the security, accountability, and operational excellence required for modern configuration management at scale.