Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is possible to add files inside a submodule folder to the parent GIT repository?

I have one GIT repository: my_git_repo and I added a submodule: my_git_repo\submodule That is OK, now:

Is possible to add files (and change ?) to submodule but keep the tracking in the parent "my_git_repo" repository?

All I want is to be able to update the submodule but still make some changes and additions on my own.

Ideas or suggestions ? Any other way to do it nicely?

like image 256
KammutierSpule Avatar asked Aug 13 '14 13:08

KammutierSpule


1 Answers

Is possible to add files (and change ?) to submodule but keep the tracking in the parent "my_git_repo" repository?

Yes, but for each new commit you will make in the submodule, you will need to:

  • push those commit to the upstream repo of that submodule (the repo which this submodule is the clone of)
  • go back to the parent repo, git add and git commit (because the gitlink will have changed, gitlink being the special entry in the index which records the SHA1 of the submodule repo).

The second step doesn't have to be done for every commit done in the submodule, but it will have to be done eventually, in order to record the next stable state of the submodule.


If the submodule is a public repo, then you need to fork it (GitHub, BitBucket), and change it remote 'origin':

cd /path/to/submodule
git remote rename origin upstream
git remote add origin /url/of/the/fork

Then you can push to the submodule repo.

To update the submodule repo with new commits coming from the original repo (that you have forked), see "Pull new updates from original Github repository into forked Github repository"

enter image description here

like image 83
VonC Avatar answered Sep 28 '22 09:09

VonC