Create three GitHub repos (Main + Frontend + Backend), initialize and push each local folder to its remote, and add the frontend & backend as submodules inside the main repo (and how to work with them later).
Quick notes before you start
Choose one authentication style: SSH (recommended) or HTTPS.
SSH repo URLs look like git@github.com:yourname/backend.git.
HTTPS URLs look like https://github.com/yourname/backend.git.
Replace yourname with your GitHub username (or org).
I assume your local folder layout is:
~/projects/MyApp/
├─ backend/
└─ frontend/
1) Create the three repos on GitHub
Go to GitHub → New repository
MyApp (main)
backend
frontend
Do NOT initialize with README if you plan to push an existing local repo (optional either way).
2) Initialize and push backend (if not already a git repo)
From your local backend folder:
cd ~/projects/MyApp/backend
# initialize if needed
git init
git add .
git commit -m "Initial backend scaffold"
# add remote (SSH example)
git remote add origin git@github.com:yourname/backend.git
# or HTTPS:
# git remote add origin https://github.com/yourname/backend.git
git branch -M main
git push -u origin main
Repeat the same for frontend:
cd ~/projects/MyApp/frontend
git init
git add .
git commit -m "Initial frontend scaffold"
git remote add origin git@github.com:yourname/frontend.git
git branch -M main
git push -u origin main
3) Create the top-level MyApp repo locally and add submodules
Create the parent repo and add the two as submodules:
cd ~/projects
# if you already have a MyApp folder with the two subfolders, use that:
cd MyApp
# initialize main repo
git init
git add .
git commit -m "Init top-level MyApp repo"
# Add submodules (SSH)
git submodule add git@github.com:yourname/backend.git backend
git submodule add git@github.com:yourname/frontend.git frontend
# If you used HTTPS earlier, use HTTPS URLs:
# git submodule add https://github.com/yourname/backend.git backend
# Commit the submodule references
git add .gitmodules backend frontend
git commit -m "Add backend & frontend as git submodules"
# Connect and push the main repo to its remote
git remote add origin git@github.com:yourname/MyApp.git
git branch -M main
git push -u origin main
Now your main repo contains a .gitmodules file and each subfolder is a submodule pointing at the other repos.
Common submodule commands you’ll need
Clone the main repo with submodules:
git clone --recurse-submodules git@github.com:yourname/MyApp.git
# or if already cloned:
git submodule update --init --recursive
Pull updates for submodules:
# update submodule pointers to the commit recorded in the superproject
git submodule update --remote --merge --recurse-submodules
# or enter the submodule and pull normally
cd backend
git checkout main
git pull origin main
# then in top-level repo
cd ..
git add backend
git commit -m "Update backend submodule pointer"
git push
Work inside a submodule (typical workflow)
cd backend
make changes, git add, git commit
git push origin main
go to main repo root: git add backend (this stages the new SHA pointer)
git commit -m "Bump backend submodule to latest"
git push origin main
Remove a submodule:
git submodule deinit -f path/to/submodule
git rm -f path/to/submodule
rm -rf .git/modules/path/to/submodule
git commit -m "Remove submodule"
git push
Helpful tips & gotchas
.gitmodules lives in the main repo and records the submodule URLs/path.
Submodules are pinned to commits — the main repo records the exact commit SHA for each submodule; updating requires committing the new pointer in the main repo.
When collaborating, remember to run git submodule update --init --recursive after cloning.
If you prefer easier workflows later, consider Git subtrees (different tradeoffs) — but for independent projects submodules are ideal.
CI: each repo can have its own CI (recommended). The main repo CI can optionally git submodule update --init --recursive to include submodule code during builds.
If you want, I can:
Produce the exact gh repo create commands for your GitHub username, or
Generate a small script that creates the three repos (via gh) and adds submodules automatically.
Which one shall I generate for you?