- 07 Dec, 2025 *
I’m cleaning up all my stray repositories and placing them into more sensible mono-repos. This is mainly to make my life easier when wanting to work on something random. The current structure looks a bit like:
- All ongoing projects under one repo
- All homelabbing stuff is split into 2: one public, one private (secrets are still handled properly)
- One for my writing and knowledge-acquisition
pages(this is new and will serve a purpose later)
This is a fairly boring process by hand, and that is why bash exists! Here’s the script I used to dump whole repos into subdirs in a new repo, while preserving all their history. This is extra beneficial if the proje…
- 07 Dec, 2025 *
I’m cleaning up all my stray repositories and placing them into more sensible mono-repos. This is mainly to make my life easier when wanting to work on something random. The current structure looks a bit like:
- All ongoing projects under one repo
- All homelabbing stuff is split into 2: one public, one private (secrets are still handled properly)
- One for my writing and knowledge-acquisition
pages(this is new and will serve a purpose later)
This is a fairly boring process by hand, and that is why bash exists! Here’s the script I used to dump whole repos into subdirs in a new repo, while preserving all their history. This is extra beneficial if the project becomes good enough to warrant going back into its own repo. This script is actually pretty straight forward but is *nix only, thanks to the xargs. You can probably use git filter-repo but I wanted a result quickly and someone on SO had such as nixxy solution.
#!/bin/bash
REPO=$1
REPOMIG=$REPO"migration"
git remote add $REPO ssh://git@codeberg.org/{YOUR_USERNAME}/$REPO.git
git fetch $REPO
git branch $REPOMIG $REPO/main
git checkout $REPOMIG
mkdir $REPO
git ls-tree -z --name-only HEAD | xargs -0 -I {} git mv {} $REPO
git commit -m "migrated $REPO to $REPO/"
git checkout main
git merge --allow-unrelated-histories -m "Assimilated $REPO" $REPOMIG
git push -u origin main
git remote rm $REPO
Now I just need to make a script that does the opposite (although I don’t actually know when that would come in handy).
Apologies if you’re in dark mode and the codefence is blinding you. My CSS appears to no longer be working, but that’s what I get for not checking this blog for 10 months.