When I set up this website, I find I need to have some nested git repo hierarchy. For example, the theme always has an individual repo and I also put the entire hexo website in a git repo. To make this hierarchy more manageable, it is a good practice to add sub git repo as submodules.
If you are using git server such as github, then you are set by simply typing the commands to set up two git repo and push to remote server and then use
1 | git submodule add ./dir/to/submodule |
to put everything not ignored to the server.
However, if you are using a git server set up by yourself, you may wonder how you should set the remote URLs for the main git repo and submodule git repo.
Instead of create two git repos in same directory to make the two repos for main and submodule are in the same level on server, we should create the server repos nested.
For example, if our main git repo named main, and our submodule repo named submodule, then we might need to perform the following actions and get the following hierarchies.
On Server:
1 | # go to needed dir |
On Local Machine with initial or developed codes:
1 | # get into directory and create file |
On another Local Machine which want to clone this repo:
1 | # clone a repo with all submoduel |
Then you will have a repo named main with submodule named submodule.