Include external repositories as submodules — clone, update, and remove them cleanly.
Git Submodules
# Add submodule
git submodule add https://github.com/user/lib.git libs/mylib
# Clone repo with submodules
git clone --recursive https://github.com/user/repo.git
# or
git clone https://github.com/user/repo.git
git submodule update --init --recursive
# Update submodule to latest
cd libs/mylib
git pull origin main
cd ../..
git add libs/mylib
git commit -m "chore: update mylib submodule"
# Update all submodules
git submodule update --remote
# Remove submodule
git submodule deinit libs/mylib
git rm libs/mylib