0

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 2

1
  1. Your new branch will include submodule.
  2. 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 
Sign up to request clarification or add additional context in comments.

Comments

0

Yes it will include the submodule but it will not commit f1 to the submodule's repo.

Think of submodule as a subrepo. It is a separate repository REFERENCED in your current repo. Imagine that many team/repo is referencing/using that repository via submodule too.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.