Skip to content

redjax/Mothership

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

396 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›Έ Mothership

Mothership repo img

Submodule Metadata Refreshed
2026-04-12 05:57 UTC

Created At Last Commit Commits this year Repo size


Mothership is a "meta" repository that brings together my core machine scripts, configurations, and dotfiles. Each project is a Git submodule, an independent repository connected here to form a unified hub for managing my development environment.

Clone this repository, then pull in the "fleet" with git submodule update --init --recursive.

Table of Contents

Purpose

I use git to manage a lot of my configurations, scripts, and tools (like my CLI swiss army knife syst). Instead of cloning each of my "core" repositories individually, I can clone this repository and extract the submodules to their own paths.

This repository started as a way for me to practice working with Git submodules, and has turned into my configuration hub.

Usage

Clone the repository and initialize submodules:

git clone [email protected]:redjax/Mothership # or https://github.com/redjax/Mothership.git
cd Mothership
git submodule update --init --recursive

Alternatively, you can clone & initialize in 1 step:

git clone --recurse-submodules <mothership-repo-url>

If you want to always pull submodule changes when they are updated, set the repository's submodule.recurse to true:

git config submodule.recurse true

Note

If you use go-task/task, you can run task init to perform initial clone setup.

Submodules

Table of the submodules found in the modules/ directory

Name Repository Description
Ansible https://github.com/redjax/Ansible My Ansible monorepo, with collections, roles, & playbooks for managing my homelab.
cheatsheets https://github.com/redjax/cheatsheets My personal manpages. Includes a Go CLI for reading and managing cheatsheets.
docker_templates https://github.com/redjax/ A large repository containing many Docker/Docker Compose containers for services I've self-hosted.
dotfiles https://github.com/redjax/dotfiles My Linux dotfiles, managed with Chezmoi.
emacs https://github.com/redjax/emacs My Emacs configuration.
git_dir https://github.com/redjax/git_dir My ~/git directory as a repository.
helix https://github.com/redjax/helix My Helix editor configuration.
neovim https://github.com/redjax/neovim A repository containing my neovim configuration(s), plus management scripts & cross-platform support.
Notetkr https://github.com/redjax/Notetkr Go app for taking notes/journal entries in the terminal.
PowershellModules https://github.com/redjax/PowershellModules Powershell modules I've written for work or personal use. I don't generally publish them, I just copy/paste or download them to my $PATH.
PowershellProfile https://github.com/redjax/PowershellProfile My Powershell profile with custom modules & functions.
syst https://github.com/redjax/syst A "swiss army knife" CLI utility written in Go.
system_scripts https://github.com/redjax/Mothership A repository I've been adding to for many years (despite what the commit history shows), contains many scripts I've created or straight up copied (where legal, thank you to everyone who figured things out before me!) for multiple versions of Linux & Windows.
templates https://github.com/redjax/templates My templates monorepo, where I store copy/paste-able versions of pipelines & other code.
Terraform https://github.com/redjax/Terraform My Terraform monorepo, where I store Terraform modules I write for myself.
Toolbelt https://github.com/redjax/Toolbelt Dynamic README.md file populated by a JSON file & Python script. An awesomelist-style collection of tools I use.
wezterm https://github.com/redjax/wezterm My Wezterm configuration.

Deploying submodules

The Mothership can deploy submodules to paths on the filesystem by "cloning" the submodule to that path. This initializes a standalone repository with the Mothership repository's path as its remote.

For example, to deploy the Ansible module to ~/Ansible:

git clone . ~/Ansible

If you cd ~/Ansible and run git remote -v, you will see the remote is the local Mothership repository's path:

git remote -v
origin  /path/to/Mothership/modules/Ansible/. (fetch)
origin  /path/to/Mothership/modules/Ansible/. (push)

You can leave this configuration as-is, so you will need to update the Mothership's submodules before doing git pull to update the local repository. This centralizes updates, and can help control which version is checked out locally, which can be useful for app configurations.

You can also change the remote back to the module's original repository. For example, set the ~/Ansible repository's remote back to [email protected]:redjax/Ansible.git:

git remote set-url origin "[email protected]:redjax/git_dir.git"
git checkout main

This separates the repository clone from the Mothership completely. It is as if you ran git clone https://github.com/redjax/Ansible.git.

Python deployment script

The do_deployment.py script can clone repositories to paths on the host, automating the process of cloning out of the Mothership repository and optionally setting the remote back to the submodule's origin.

Start by creating a deploy.json file (see the example.deploy.json file for the structure):

{
    "repositories": [
        {
            "name": "",
            "target": "",
            "branch": "",
            "mothership_remote": false
        }
    ]
}
  • name should match one of the submodule paths in the modules/ directory.
  • target is the path on the current machine where you want the cloned repository to exist.
  • branch (default should be main) sets the branch to checkout after cloning.
  • mothership_remote is a boolean value. When true, the submodule's remote will be the path where you cloned Mothership (i.e. ~/Mothership).
    • If you leave "mothership_remote": true, the cloned repository will be pointed back at the Mothership directory.
    • This means to pull updates, you need to cd back to the Mothership remote and update the submodules, then cd to the cloned repository and run git pull.
    • This can help to control updates to configurations; you won't accidentally pull changes until you switch back to the Mothership repository and pull the submodule.

Run the scripts/deploy/do_deployment.py script with -c /path/to/your/deploy.json.

Updating submodules

Run this command to recursively pull the main branch of each submodule:

git submodule foreach git pull origin main

Adding submodules

git submodule add https://github.com/youruser/repo_name.git local/path/to/repo_name

Removing submodules

git submodule deinit -f local/path/to/repo_name
git rm local/path/to/repo_name
rm -rf .git/modules/local/path/to/repo_name

## Commit changes to MetaRepo
git commit -m "Remove local/path/to/repo_name submodule"

Change submodule remote

Edit .gitmodules file, update the URL of the submodule, then run the following to update MetaRepo:

git submodule sync
git submodule update --init --recursive

Move a submodule in the repository

The easiest method is to use git mv:

git mv old/path/to/submodule new/path/to/submodule

Doing this moves the submodule directory, updates the .gitmodules file with the new path, and adjusts internal Git config as needed.

After moving a submodule, commit like this:

git add .gitmodules
git add -u
git commit -m "Move submodule to new path"

Taskfile tasks

The Taskfile.yml file defines tasks/automations for go-task/task. This allows for powerful automation, and can be used locally or in pipelines.

To see a list of tasks that can be run, use:

task -l

Troubleshooting

Submodule updates in pipeline not applied locally

When the pipeline that updates submodules runs and pulls changes on the remote, you need to also pull the submodule changes locally. This can be done with git pull --recurse-submodules, or you can set the local repo to always pull submodule changes on a git pull with:

git config submodule.recurse true

Links

About

πŸ›Έ All aboard the mothership πŸ“‘

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors