Say I create a git repo with a submodule in it. Then I clone the repo (with the submodule) and create a branch in my local repo. Will that branch include the submodule? If I change 2 files in the repo, f1 an f2, with f1 in the submodule and f2 outside of the submodule, and then commit my change, will that commit include both files? If I then push the commit, will that change the remote submodule?
2 Answers
- Your new branch will include submodule.
- Submodule - is a separate repository. So in order to save changes, you need to commit first of all to submodule repository. Then, you could commit to your main repository that submodule has been changed. Overall, "main" repository points to some specific commit of submodule repository.
cd SubmoduleRepo git commit --all -m "Change submodule code" // commit changes directly to submodule repo git push submodule_origin // push changes to remote submodule repo cd .. // go back to main repository working folder git add SubmoduleRepo // commit that submodule repo was changed git commit -m "Updated submodule" git push origin // push changes for the main repo