Skip to content

bernardlawes/Git-Bash-Toolbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŒ€ Git Bash Automation Toolkit

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.

⚑ Purpose

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.

βœ… Features

  • πŸš€ 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

πŸ› οΈ Requirements

  • Bash (Unix-like environment or Git Bash for Windows)
  • GitHub CLI (gh) (for repo creation/editing)
  • jq (for JSON parsing)

πŸ—‚οΈ Directory Structure

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.

πŸ§ͺ Example Usage

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 from JSON:

# 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

About

A suite of Bash scripts to simplify and automate the creation, editing, management of multi-project Git repositories with Git submodules

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages