Skip to content

About

Fix, initialize, and sync Git submodules in one command. Prevent broken states and dependency drift.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Git Submodule Sync Automation

Fix and sync all Git submodules in a single command.

Designed for multi-repository projects where submodule drift and manual sync issues become recurring problems.


🚀 Overview

Automates the synchronization, initialization, and safe updating of Git submodules. Designed to prevent broken states, out-of-sync dependencies, and manual drift in multi-repository projects using .gitmodules.


✨ Key Features

  • Dynamic Discovery: Automatically detects and registers submodules defined in .gitmodules even if they haven't been cloned yet.
  • Ignore Logic Control: Supports granular per-submodule synchronization levels (none, dirty, all) via the standard ignore property.
  • High-Intensity UI: Uses a vivid ANSI color palette (Bright/Bold) for clear status reporting and professional terminal feedback.
  • Robust Error Handling: Wraps the entire synchronization process in a fail-safe block with definitive success ([DONE]) or failure ([ERROR]) reporting.
  • Auto-Committing: Optionally commits and pushes local changes within submodules to keep dependencies up to date.

🛠️ Installation

  1. Clone this repository or copy sync-automation.sh to your project root.

  2. Grant execution permissions:

    chmod +x sync-automation.sh

📋 Configuration

The script reads the standard .gitmodules file. You can control the behavior of each submodule using the ignore property:

[submodule "example-module"]
    path = examples/example-module
    url = https://github.com/user/example-module
    branch = main
    ignore = none  # Default: Full sync & auto-commit

Ignore Levels

  • none: (Default) Pulls remote changes and auto-commits local modifications.
  • dirty: Pulls remote changes but ignores local modifications (won't auto-commit).
  • all: Completely skips the submodule during the synchronization process.

⚡ Usage

Simply run the script from the root of your Git repository:

./sync-automation.sh

The script will:

  1. Detect your repository name.
  2. Iterate through all submodules.
  3. Fetch/Pull the latest commits for the specified branches.
  4. Handle local changes according to your ignore settings.
  5. Update the submodule pointers in your main repository and push them.

🤝 Contributing

Contributions are welcome! Keep code modular, readable, and tested. Pull requests should include a clear description and working example.


📝 License

MIT © 2026 sandokan.cat

Use it. Modify it. Share it. Attribution is appreciated.


⚠️ Disclaimer

All tools and utilities in this repo are provided "as is", without warranties. Use at your own risk. Intended for personal, educational, and professional use.

About

Fix, initialize, and sync Git submodules in one command. Prevent broken states and dependency drift.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages