git management subprojects
For some of the larger projects, in order to facilitate multiplexing, often need to extract subprojects. The UI project generally common, underlying logic common, shared third-party libraries do git management sub withdrawn. This time git provides two ways subproject management, submodule and subtree.
It was made for differences submodule and subtree of a summary: submodule IS Link; subtree IS Copy .
submodule
container and each module is independent of the git repo
submodule need to do a commit
Parent repo need to commitID sublayer also push up
submodule pit
After submodule update and push, but did not push the main repo new meta file to the server, another developer after git pull submodule will stay in an unmodified version.
Assuming everything is normal, the main repo are subject to change file date submodule, developers git submodule update submodule will not cut any branc large column git git subtree submoudle VS H, so the default submodule of the repo will stay in a detached HEAD ( free state).
Modify the pit submodule
Common practice to cut submodule directory, and then make changes, then commit and push.
If you accidentally forget to switch to the branch, but also made a submission, you can save with cherry-pick command.
- The HEAD branch with git checkout to switch from a free state to the branch, this time, git will submit a report Warning say there is not on the branch, keep in mind this change-id submitted (if the change-id is aaaa)
- File with git cherry-pick aaaa and will be submitted to the branch just in.
- Submitted by git push updates to the remote database.
subtree
Only a git repo
Just do a commit