add submodule
|
|
If this repo has not previously been used submodule then Git will create a directory in the directory called .gitmodules , which records the URL of the remote repo and the submodule in this project path.
After executing this command submodule and .gitmodules will automatically staged, this time can commit and push.
Update submodule
Individual repo update is too much trouble, it is necessary to separate directory under execution git pull
to pull the upstream code, but that would be more secure; all at once to update all of submodule can use this foreach
command:
|
|
Remove submodule
I thought there will be like git submodule rm
such an instruction, the result is not even, you must manually remove the hard ground one by one, not knowing what not to implement this directive considerations, I hope that future versions can add to it.
Remove submodule has the following steps to do, first remove the submodule directory from the version control system:
|
|
Again to modify .gitmodules , remove the unwrought submodule, for example:
|
|
Not yet finished! But also modify the contents of .git / config , with. Gitmodules , the need to remove the submodule deleted, and finally commit.
clone when the submodule together to catch down
Implementation of git clone
Git clone does not automatically come together when submodule must be added --recursive
recursive parameter, so you can catch all associated submodule in submodule down together:
|
|
If you have been caught to find submodule is empty, you can use the following instructions to catch, init
will be registered in _.git / config` remote repo URL and local path:
|
|
Or merged into one line git submodule update --init --recursive
can, if upstream someone to turn over .gitmodules , it seems that local end also using this method update.
Explanation of instructions
git submodule init
: According to .gitmodules name and URL, these information will be registered to . *Git */ config , but not .gitmodules not removed submodule, the use of this directive and no way to automatically delete. Git / config related content, you must manually delete ;git submodule update
: According to registered (that is, .git / config ) submodule to update, such as clone lost submodule, which is the last paragraph of the method, so the implementation of this instruction before the best plus--init
;git submodule sync
: If the submodule’s remote URL changes, you can correct the URL in .gitmodules , and then execute this command, the submodule’s remote URL will be corrected.