Skip to content

OctaEDLP00/AddGitSubmodules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Add-GitSubmodules

Add-GitSubmodules is a PowerShell utility designed to simplify the process of adding and managing Git submodules within a main repository.

This module automates several tedious Git workflows, allowing you to quickly link and initialize one or more submodules in a single command. It supports both remote and local repositories, custom submodule paths, and optional push behavior.

It also includes intelligent user detection — retrieving your GitHub username automatically from Git configuration or remote URL — and interactively confirming it before proceeding.

🚀 Features

  • Automatically detects or clones the main repository if needed.
  • Accepts multiple submodules at once (via array or hashtable).
  • Supports custom target paths per submodule.
  • Automatically initializes and updates all submodules recursively.
  • Optionally skips pushing changes using the -NoPush flag.
  • Verifies Git installation and ensures clean repo state.
  • Confirms and stores your GitHub username for future submodule URLs.

📝 Notes

  • Make sure Git is installed and available in your system PATH.
  • If the main repository URL is remote, it will be cloned automatically.
  • Username detection is based on your Git config (git config --get user.name).
  • You can safely re-run the command; existing submodules will be skipped.

🧩 Installation

# Import the module manually
Import-Module Add-GitSubmodules

🧠 Usage

Basic Usage

# Add a single submodule by name
Add-GitSubmodules -Main "PowershellModules" -Submodules "OhMyPoshRandomTheme"

Advanced Usage

# Add multiple submodules with custom target paths
Add-GitSubmodules -Main "PowershellModules" `
  -Submodules @(
    @{ name = "OhMyPoshRandomTheme"; path = "modules/ohmyposh" },
    @{ name = "AnotherModule"; path = "modules/tools" }
  )

Prevent Automatic Push

# Prevent automatic push after adding submodules
Add-GitSubmodules -Main "PowershellModules" -Submodules "ExampleModule" -NoPush

🧱 Project Structure

AddGitSubmodules/
├── src/
│   ├── AddGitSubmodules.psm1
│   └── AddGitSubmodules.psd1
├── examples/
│   └── ExampleProfile.ps1
├── docs/
│   └── INSTALLATION.md
├── Publish.ps1
└── README.md

🪄 Example Output


🧑‍💻 Author

OctaEDLP00 💡 GitHub: @OctaEDLP00

🪪 License

MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published