A JSON driven collection of Bash scripts to simplify and automate the creation, management, editing, removal, and pushing of multi-project Git repositories with Git submodules β including support for multi-repo setups with submodules, custom structures, and modular workflows.
In addition to automating the creation of the main Git repository and its associated submodules, this toolkit also supports programmatic population of each submodule with fully structured project content. For example, in C#-based workflows, users can define the project type (e.g., class library, console app, WinForms, etc.) and specify custom directory structures, allowing the toolkit to scaffold complete, ready-to-build projects inside each submodule β all from a single configuration file or scripted workflow.
Managing Git submodules, nested repositories, and batch repo creation can be tedious and error-prone. This toolkit streamlines those operations into fast, repeatable Bash commands β ideal for mono-repos, microservice setups, modular codebases, or multi-project pipelines.
- π Create main repos + submodules from a single JSON config
- π Pull, push, or clone all submodules recursively
- π Initialize, sync, and update submodule links
- π§Ή Remove or detach submodules safely
- π οΈ Batch edit repo metadata (descriptions, remotes, visibility)
- π Generate or sync
.gitmodules,.gitignore, and other scaffolding - π§ͺ Dry run mode for safe previews before executing changes
- Bash (Unix-like environment or Git Bash for Windows)
- GitHub CLI (
gh) (for repo creation/editing) jq(for JSON parsing)
git-bash-toolkit/ βββ create_repos.sh # Create repo + submodules from config βββ update_submodules.sh # Pull latest changes for all submodules βββ remove_submodule.sh # Cleanly remove a submodule βββ sync_metadata.sh # Sync descriptions or remote info βββ .gitignore # (Optional) Ignore system/temp files βββ git-modules-config.json # JSON config with repo structure
π¨ Safety Tips Always run git status before/after script execution.
Use a test branch or dummy org for initial runs.
When modifying remote repos, ensure GitHub CLI is authenticated.
π¦ To Do Add logging support
Add backup/restore mode
GitLab support
π€ Contributing PRs and suggestions welcome! This toolkit is evolving with real-world usage β feel free to fork and enhance for your setup.
π License MIT License β use freely and modify as needed.
JSON Config Structure
{
"main_repo": "MainProject",
"visibility": "private",
"submodules": [
{
"name": "Utils",
"path": "libs/utils",
"visibility": "public",
"archetype": "classlib"
},
{
"name": "UI",
"path": "apps/ui",
"visibility": "private",
"archetype": "winforms"
}
]
}
# Create a full repo structure based on config.json
./create_repos.sh ./git-modules-config.json
# Update and Sync Submodules
./update_submodules.sh
# Remove a submodule Cleanly
./remove_submodule.sh path/to/submodule