0

Hey guys I have a main repo with submodules and I intend on working on most of the files as a new branch. While the main repo doesn't need to be pushed to the remote master my sub modules would probably need to be. Giving that I am working on the files as new branches( both in main and submodule) I ask the following:-

  1. Should I be tracking the submodules files via the main repo?
  2. Do the changes in the submodules get reflected immediately in the main repo regardless of committing or not?
  3. Is it ok to track specific files from submodules in the main repo?
  4. If I make changes in the submodule I have to do two commits one in the submodule and one on the main repo can I either automate this process or can I make one commit from the main repo?
Kendall
  • 5,065
  • 10
  • 45
  • 70

1 Answers1

0

A main repo tracks submodule with gitlink, a special entry in the index.

That means any modification in a submodule will have to be committed, and pushed to its upstream repo, and then committed in the main repo.

So:

  1. Should I be tracking the submodules files via the main repo?

No: the main repo only tracks the current submodule HEAD SHA1 as a gitlink.

  1. Do the changes in the submodules get reflected immediately in the main repo regardless of committing or not?

The submodule is just a subfolder in the main repo: any change is visible from the main repo since the subfolder is visible.
But that change will be recorded (meaning others will be able to clone the main repo and see that same change in the submodule) only when the submodule will have added, committed and push said change, and when the main repo has done the same (for recording the new gitlink entry)

  1. Is it ok to track specific files from submodules in the main repo?

The main repo only tracks the gitlink, nothing else.
The main repo can also specify (in the .gitmodules) that it wants to track a branch of the submodule, meaning it will update the submodule to the latest of a branch.

  1. If I make changes in the submodule I have to do two commits one in the submodule and one on the main repo can I either automate this process or can I make one commit from the main repo?

Yes, two commits (and two git push) are required.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • thanks for this feedback...ok well as incident would have it I did some `git add` to the submodule( submodule is just a subfolder) because some of the changes made in he submodule are specific to the project and would not be pushed to the repo...So I'll untracked them – Kendall Sep 20 '15 at 18:51