[Git] Git submodule basic commands

  • Clone a repo tree
git clone --recurse-submodules remote_url
  • Link a submodule
git submodule add submodule_remote_url local_linking_path
# Then commit & push to the main repo
  • Pull from a submodule
# Pull from specific branch
git pull --recurse-submodules my-branch
# Then commit & push to the main repo
  • Update a submodule
cd submodule_path
# Do the commits and push normally, the changes will be pushed to submodule repo

cd main
# Then do a commit and push to the main module
  • Reset submodule head to currently stored reference
git submodule update --init

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *