Git submodule Add submodule Engineering Modify submodule Update submodule summary more references
Git submodule
The recent use of this command, mainly in order to implement in a git warehouse, the introduction of other Git warehouse, this applies to you want to introduce other libraries in the main project, the main project in the form of submodule, the subproject can have their own git operations, such as commit, Push, rebase and so on.
Here I use a practical example to introduce the use of this command, do not know if everyone has been embedded in the original project react Native. The alumni who are familiar with the react native project know that there is an Android project, as shown below:
You will find that there will be an iOS project, our client development will generally maintain a git warehouse, in order to allow Android and iOS are not the same project commit, mainly for the convenience of maintenance, so I think how to introduce in the RN Project Android and iOS project , understand our needs, we know that there are submodule in git, so go straight to the bottom. Add Submodule Engineering
Git submodule add http://git.code.oa.com/TCW/Crowdsource-android.git android
After executing this command, you can see the change information through git status:
On Branch master
Your Branch are up-to-date with ' origin/master '.
Changes to is committed:
(use "git Reset head <file> ..." to unstage)
new file: . gitmodules
New File : Android
Then add the child modules:
git Add. getmodules android
git commit-m "add Android submodule."
Git submodule init
OK, here you have successfully added a submodule. Modify Submodule
Into the submodule.
CD Android
My submodule here is Android.
When I changed the contents of the Android project, git status:
Submit Submodule content to remote:
git Add.
git commit-m "embed react Native"
git push
After submitting, look at the submodule changes in the main project:
CD..
git status
The following figure:
At this point, the changes to the main project are submitted:
git Add.
git commit-m "update android submodule"
git push
OK, the submodule has been successfully modified here. Update Submodule
Here is a problem, you completed the submodule in your own machine to add and modify, that other students want to update how to do.
Run the following command in the main project root directory:
Git submodule foreach git pull
You also need to update the following submodule:
cd Android
git pull
Ok so that other team members will be able to pull up the latest engineering code. Summary
about how to introduce the Android project through Submodule in the RN project has been basically done, and the clone submodule and remove submodule operations will not be demonstrated, you can refer to the links provided below. More References
Using Git submodule Management sub-module