git clone --recurse-submodules https://github.com/VMahluza/quickcoach.gitThis will:
Clone your main repository. Automatically initialize and clone the
frontendandbackendsubmodules.
If you've already cloned the main repo without --recurse-submodules:
git clone https://github.com/VMahluza/quickcoach.gitThen run:
cd quickcoach
git submodule update --init --recursiveLet's say you made changes to the backend
- Navigate into the submodule
cd backend
- Check your current branch
git status
git branch
- Add, commit, and push your changes
git add .
git commit -m "Your change message"
git push originAfter pushing your submodule changes:
Go back to your main repo root:
bash cd ..Git will detect the submodule has a new commit:
bash git status
Commit the submodule reference update:
git add backend # or frontend
git commit -m "Updated backend submodule to latest commit"
git push origin mainThis tells Git: "Hey, the main repo now points to a newer commit of the backend/frontend."
Step What you do 1 cd backend or cd frontend 2 Make changes, commit & push to the submodule 3 cd .. back to main repo 4 git add backend 5 Commit and push the submodule update in main repo
Each submodule has its own Git history. You must push from inside the submodule for changes to be saved remotely. Updating the submodule pointer in the main repo ensures collaborators get the correct version.
If your colleague pushed both: Changes inside backend/ or frontend AND updated the main repo to point to the latest submodule commits Then run this:
git pull --recurse-submodules
git submodule update --init --recursiveThis fetches the main repo and syncs submodules to the commit your colleague set.
If you only want to get the latest commits from the submodules (in case your colleague pushed, but didn’t update the main repo): For frontend:
cd frontend
git checkout main # or the branch they pushed to
git pull
cd ..For backend:
cd backend
git checkout main
git pull
cd ..
git submodule updatesyncs to the commit specified in the main repo.
git pull(inside a submodule) gets the latest code from the submodule’s own branch.
- If the main repo was updated by your teammate to point to newer commits, you can just do a top-level pull with
--recurse-submodules.
If you're working with branches in submodules (not pinned commits), you can set this up to always track latest like this:
git config -f .gitmodules submodule.backend.update remote
git config -f .gitmodules submodule.frontend.update remote
git submodule update --remoteAfter cloning, submodules are locked to a specific commit. So unless the main repo was updated to reference newer submodule commits, your submodules will appear outdated.
Tell Git to track remote HEAD for submodules
git config -f .gitmodules submodule.backend.update remote
git config -f .gitmodules submodule.frontend.update remoteNow update to the latest commits in both submodules
git submodule update --remoteThen commit the updated submodule references in the main repo:
git add backend frontend
git commit -m "Updated submodules to latest commits"
git push origin mainFrom now on, git submodule update --remote will pull latest from default branches of submodules.