🧠 Git extension for intelligent code sharing & synchronization between repositories without duplication.
Project description
Brain: Intelligent Asset & Code Synchronization for Git.
🧠 Eradicate code & asset duplication across projects! Brain repositories serve "neurons"—your chosen files, folders, and their dependencies—which Brain then intelligently and selectively syncs into any Git consumer repository. Think submodules, on steroids, and without the headaches.
Is your organization grappling with the complexities of managing shared configurations, critical build infrastructure, or versioned design assets across a sprawling Git landscape? Are you seeking a more robust, governable alternative to the limitations of Git submodules or the chaos of ad-hoc file sharing?
Brain is a language-agnostic Git extension, architected with enterprise-scale challenges in mind. It provides a powerful framework for sharing and synchronizing any versioned asset—we call them "neurons." Whether it's Terraform modules, JSON schemas, CI/CD pipeline configurations, security policies, legal templates, or critical software libraries and their dependencies, Brain is designed to ensure they are managed centrally with clarity and consumed consistently.
Our vision is to provide a foundational layer for reducing silos, accelerating secure delivery, and enforcing universal standards across your most critical version-controlled assets and code.
🔥 Why Brain Will Revolutionize Your Workflow (And Save Your Sanity)
Traditional methods for sharing versioned assets and code are often cumbersome and error-prone. Here’s how Brain fixes them:
-
🤯 Obliterate Submodule Overload & Complexity:
- The Pain: Git submodules are clunky, bring in entire repositories when you might only need a fraction, and their state management is a constant source of "did I update it right?" anxiety, often leading to detached HEADs and CI failures.
- The Brain Solution: Share only the specific files or directories (neurons) you need from a Brain repository. Synchronization is explicit and integrated (e.g.,
brain pull). No more unnecessary baggage or submodule update rituals.
-
🚫 Annihilate Copy-Paste Catastrophes & Version Drift:
- The Pain: Manual copying of assets or code across projects is a recipe for disaster, leading to version drift, bugs propagating (or critical fixes not propagating), and no single source of truth. It's technical debt accumulating interest.
- The Brain Solution: Neurons are synced from a single, version-controlled Brain repository. Updates are intentional, trackable, and consistent.
-
🎯 Pinpoint Precision Sharing for Any Asset Type:
- The Pain: Need just one configuration file, a directory of icons, or a specific build script? Submodules are too coarse. Manual copying is too risky.
- The Brain Solution: Map
configs/production.jsonfrom yourops-braintodeploy/configs/prod.jsonin your app. Sharemarketing-assets-brain::brand_guidelines/logos/tostatic/company_logos/. It's language-agnostic and works for any file or folder.
-
💻 Feels Like Git, Because It Works Intelligently With Git:
- The Pain: New tools often mean a steep learning curve, disrupting established workflows.
- The Brain Solution: Brain uses commands like
brain pull,brain push,brain status. If you know Git, you're already familiar. Brain intelligently extends your existing Git commands.
-
🧩 Clear, Controllable Configuration for Enterprise Governance:
- The Pain: "Magic" configurations that are hard to understand, debug, or audit.
- The Brain Solution: Two simple INI files (case-sensitive keys):
.brain(in the Brain repository): Defines what's shareable (which neurons) and the permissions (readonlyorreadwrite) for those neurons..neurons(in consumer repositories): Defines connections to Brain repositories and how their neurons are mapped into the local project structure. These files are human-readable and version-controllable, providing a clear audit trail.
-
🤝 Smart Conflict Resolution & Defined Contribution Paths:
- The Pain: "My version or their version?!" Sync conflicts are inevitable. Contributing changes back to a shared resource can be convoluted.
- The Brain Solution: Choose your conflict strategy (
prefer_brain,prefer_local, orpromptwith 3-way merge for text files usinggit merge-file).readwritepermissions on neurons (in.brain) combined withALLOW_PUSH_TO_BRAIN=true(in.neurons) allow consumers tobrain exporttheir improvements.
-
🔗 Dependency Sanity for Code Neurons (Python Focus, Extensible Concept):
- The Pain: Shared code often has its own dependencies. Managing these across multiple consuming projects can lead to
requirements.txthell. - The Brain Solution: Brain offers special handling for Python. If a neuron has an associated
requirements.txt(e.g.,my_neuron_dir/requirements.txt,my_neuron_dir/<dirname>requirements.txt, ormy_neuron_file.pyrequirements.txt), Brain intelligently merges these dependencies into your consumer project's mainrequirements.txtduring sync.
- The Pain: Shared code often has its own dependencies. Managing these across multiple consuming projects can lead to
🚀 Quick Start: Experience the "Aha!" Moment in Minutes
Stop wrestling, start syncing.
1. Install Brain
pip install git-brain
2. Create Your First "Brain" Repository (The Central Source)
Imagine you have a set of shared Terraform modules or CI pipeline configurations.
# Create and initialize your Brain repository
mkdir shared-infra-brain
cd shared-infra-brain
git init -b main # Or your default branch name
brain brain-init --id common-infra --description "Standardized infrastructure modules & CI configs"
# Configure what's shareable in the .brain file (created by brain-init)
# Example .brain:
# [BRAIN]
# ID = common-infra
# DESCRIPTION = Standardized infrastructure modules & CI configs
# [EXPORT]
# terraform/modules/vpc/ = readonly
# ci/pipelines/default_build.yml = readwrite # Consumers can propose improvements
# scripts/deploy_helpers.sh = readonly
# Create your actual shared assets
mkdir -p terraform/modules/vpc ci/pipelines scripts
echo "# Standard VPC Terraform Module v1" > terraform/modules/vpc/main.tf
echo "name: Default CI Build Pipeline v1" > ci/pipelines/default_build.yml
echo "#!/bin/bash\necho 'Deploy helper script v1'" > scripts/deploy_helpers.sh
chmod +x scripts/deploy_helpers.sh
git add .
git commit -m "feat: Initial set of shared infrastructure neurons"
# Optional: Push to a remote (e.g., GitHub, GitLab)
# git remote add origin <your-brain-repo-url>
# git push -u origin main
3. Use Neurons in Your "Consumer" Project
# Navigate to your existing project, or create a new one
cd ..
mkdir my-service-deployment
cd my-service-deployment
git init -b main
# Add the Brain (use file:// for local paths or http/ssh for remotes)
# Example for a local brain (adjust path as needed):
INFRA_BRAIN_PATH_ABS=$(cd ../shared-infra-brain && pwd) # Get absolute path
brain add-brain infra-main "file://${INFRA_BRAIN_PATH_ABS}" main
# Map specific "neurons" into your project. They appear like regular files/folders!
brain add-neuron infra-main::terraform/modules/vpc/::infra/modules/vpc/
brain add-neuron infra-main::ci/pipelines/default_build.yml::.gitlab-ci.yml
# Your .neurons file is created/updated, and neurons are synced!
ls infra/modules/vpc/
cat .gitlab-ci.yml
# Commit this Brain setup
git add .
git commit -m "feat: Integrate common infrastructure neurons via Brain"
4. The Effortless Daily Workflow
-
Infrastructure Update in the Brain: A new version of
default_build.ymlis committed toshared-infra-brain. -
Sync Your Service Project: In
my-service-deployment:brain pull # Recommended: pulls project changes AND syncs neurons (if AUTO_SYNC_ON_PULL=true) # OR brain sync # Just sync neurons
Your
.gitlab-ci.ymlis now updated with the latest version from the Brain. -
Proposing a Change to a Neuron (Potentially
readwrite): You've improved.gitlab-ci.yml(mapped fromci/pipelines/default_build.yml) in yourmy-service-deploymentproject. (EnsureALLOW_PUSH_TO_BRAIN=trueandALLOW_LOCAL_MODIFICATIONS=truein.neuronsfor this project if you intend to modify and export).# After committing your changes to .gitlab-ci.yml in my-service-deployment brain export .gitlab-ci.yml # OR, if you're pushing project changes anyway: # brain push --push-to-brain
The
shared-infra-brainnow has your improvements as a new commit toci/pipelines/default_build.yml(assumingreadwritepermission was effectively granted and export successful).
🌱 Current Status & Our Enterprise Vision
Brain is currently in its Alpha stage (v0.1.0). While the core functionality for sharing and synchronizing neurons is robust, we are actively working towards features and hardening. See Vision & Roadmap for details.
📖 Core Concepts: Brains, Neurons, Consumers
Refer to Core Concepts for detailed explanations.
⚙️ Configuration Deep Dive
Brain's power and control come from two straightforward INI configuration files. See Configuration Files for details.
.brain File (Located in the Brain Repository Root)
Defines the brain's identity and, crucially, what "neurons" it offers for sharing and under what conditions.
[BRAIN]
ID = global-brand-assets
DESCRIPTION = Official company branding materials and guidelines
[EXPORT]
logos/standard/color.svg = readonly
logos/standard/white.svg = readonly
fonts/primary_typeface.ttf = readonly
style_guides/corporate_identity.pdf = readonly
templates/presentations/quarterly_review.pptx = readwrite
src/shared_utils/ = readonly
configs/common.json = readwrite
[BRAIN]: Contains the uniqueIDandDESCRIPTION.[EXPORT]: Lists shareable paths and their permissions (readonlyorreadwrite). (For advanced[ACCESS]and[UPDATE_POLICY]sections, see the Configuration Files documentation.)
.neurons File (Located in the Consumer Repository Root)
Specifies which Brains this project connects to, how neurons are mapped into the local filesystem, and the policies for synchronization.
[BRAIN:brand-kit]
REMOTE = git@github.com:our-org/global-brand-assets.git
BRANCH = main
[BRAIN:ci-cd-pipelines]
REMOTE = file:///opt/shared-git/common-ci-cd-pipelines
BRANCH = stable
[SYNC_POLICY]
AUTO_SYNC_ON_PULL = true
CONFLICT_STRATEGY = prompt
ALLOW_LOCAL_MODIFICATIONS = false
ALLOW_PUSH_TO_BRAIN = false
AUTO_SYNC_ON_CHECKOUT = true
[MAP]
main_logo = brand-kit::logos/standard/color.svg::src/assets/images/company_logo.svg
style_guide_pdf = brand-kit::style_guides/corporate_identity.pdf::docs/branding/main_style_guide.pdf
default_ci = ci-cd-pipelines::gitlab/standard_build.yml::.gitlab/ci/default.yml
shared_utilities = brand-kit::src/shared_utils/::lib/common_utils/
common_config = brand-kit::configs/common.json::config/app_config.json
[BRAIN:<alias>]: Defines a connection to a brain, itsREMOTEURL, andBRANCH.[SYNC_POLICY]: Sets rules for synchronization, conflicts, and local changes. (Defaults apply if not specified).[MAP]: Maps neurons using the formatkey_name = brain_alias::path_in_brain::path_in_consumer. (Consult the Configuration Files documentation for a comprehensive explanation of all options and defaults.)
🎛️ Full Command Reference
Brain seamlessly integrates with your Git workflow. Invoke as brain <command>.
See Command Reference for a detailed list of arguments and options.
Brain-Specific Commands:
brain brain-init: Initialize a directory as a new Brain repository.brain add-brain: Register an external Brain in your consumer project.brain add-neuron: Map a neuron from a Brain into your consumer project.brain remove-neuron: Unmap a neuron (optionally delete local files).brain sync: Manually synchronize neurons.brain export: Export local neuron changes back to Brains.brain list: Display configured neurons.
Git Commands Enhanced by Brain:
brain pull:git pullthen auto-syncs neurons.brain push:git pushwith neuron policy checks and optional--push-to-brain.brain status:git statusaugmented with neuron modification status.brain clone:git clonethen auto-sets-up/syncs neurons.brain checkout:git checkoutthen optionally syncs neurons.brain init:git initwith optional Brain/consumer setup flags.
💡 Advanced Scenarios & Use Cases
- Managing Environment-Specific Configurations: Use different Brain branches (e.g.,
dev,staging,prod) for configuration neurons. - Distributing Boilerplate/Templates: A "project-templates" Brain can serve skeleton structures.
- Shared CI/CD Pipelines: Standardize build/deployment by sharing pipeline configurations.
- Cross-Functional Asset Sharing: Enable marketing, legal, design teams to manage versioned assets in dedicated Brains.
🤝 Contributing & Getting Involved
Brain aims to solve a widespread problem. We welcome your expertise and feedback!
- ⭐ Star this repository on GitHub!
- 🚀 Try Brain: Integrate it into a pilot project.
- 🐞 Report Bugs & Request Features: Open an issue.
- 🛠️ Contribute: Pull requests are welcome!
📜 License
Brain is licensed under the GNU General Public License v3.0.
See the LICENSE file (expected to be in the repository root) for the full license text.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file git-brain-0.1.0.tar.gz.
File metadata
- Download URL: git-brain-0.1.0.tar.gz
- Upload date:
- Size: 70.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47e6f9973cc536acdf459e8b9d7822b56218fa776204778d6ea340d17a12ebcc
|
|
| MD5 |
080d2f08c1db2f32a2e63e4e5043b56c
|
|
| BLAKE2b-256 |
3a775101343983c42de2545bf1e0e42eedb457ee982b7774149530c941d14a45
|
Provenance
The following attestation bundles were made for git-brain-0.1.0.tar.gz:
Publisher:
publish-to-pypi.yml on FanaticPythoner/git-brain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git_brain-0.1.0.tar.gz -
Subject digest:
47e6f9973cc536acdf459e8b9d7822b56218fa776204778d6ea340d17a12ebcc - Sigstore transparency entry: 209992101
- Sigstore integration time:
-
Permalink:
FanaticPythoner/git-brain@097db4f3623f3f08245a9cd842b2031aafde2a1e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/FanaticPythoner
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@097db4f3623f3f08245a9cd842b2031aafde2a1e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file git_brain-0.1.0-py3-none-any.whl.
File metadata
- Download URL: git_brain-0.1.0-py3-none-any.whl
- Upload date:
- Size: 77.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3508a8de18fbf07ba3152e956326847f301c33e56d9753182f589021d7e892d8
|
|
| MD5 |
c2de113e6f2e50f6cb64d8e725fd1995
|
|
| BLAKE2b-256 |
f11724f2915ec6ee9430f06ce3a404d46c6978de59155bb550638b8262c1cb69
|
Provenance
The following attestation bundles were made for git_brain-0.1.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on FanaticPythoner/git-brain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git_brain-0.1.0-py3-none-any.whl -
Subject digest:
3508a8de18fbf07ba3152e956326847f301c33e56d9753182f589021d7e892d8 - Sigstore transparency entry: 209992106
- Sigstore integration time:
-
Permalink:
FanaticPythoner/git-brain@097db4f3623f3f08245a9cd842b2031aafde2a1e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/FanaticPythoner
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@097db4f3623f3f08245a9cd842b2031aafde2a1e -
Trigger Event:
workflow_dispatch
-
Statement type: