... | ... | @@ -10,11 +10,11 @@ In the following, a few hints how to get started with submodules and how to perf |
|
|
Getting started
|
|
|
----------------
|
|
|
* Start a Project on OpenVT, let's say the name is **my_awesome_project** (that one will be called 'main repository' in the following). You would like to include some other repository in there, let's say that one is called **the_other_awesome_project** (that one can be located on OpenVT or any other git server; we will refer to it as the 'submodule repository').
|
|
|
* Make a clone on your computer with git:
|
|
|
* Make a clone of the main repository on your computer:
|
|
|
```bash
|
|
|
git clone <cloning_link_for_my_awesome_project>
|
|
|
```
|
|
|
* Now browse into the folder of the clone and add the other repository as submodule:
|
|
|
* Now browse into the folder of the clone and link to the submodule repository as submodule:
|
|
|
```bash
|
|
|
git submodule add <cloning_link_for_other_awesome_project>
|
|
|
```
|
... | ... | @@ -28,7 +28,7 @@ git submodule update |
|
|
|
|
|
Updating the submodule(s) to latest commit
|
|
|
---------------------------------------
|
|
|
* By default, a submodule always points to a certain commit of the submodule repository. This does not change if you pull the main repository. In order to update also the submodulesto the latest commit, you can either just successively browse to each the submodule folder and pull the branch of your choice (in many cases, that will be 'origin master'):
|
|
|
* A submodule always points to a certain commit of the submodule repository. This does not change if you pull the main repository. In order to update also the submodulesto the latest commit, you can either just successively browse to each the submodule folder and pull the branch of your choice (in many cases, that will be 'origin master'):
|
|
|
```bash
|
|
|
git pull <remote branch name>
|
|
|
```
|
... | ... | @@ -38,7 +38,31 @@ git pull --recurse-submodules |
|
|
git submodule update --remote
|
|
|
```
|
|
|
|
|
|
Changes in submodules
|
|
|
----------------------
|
|
|
If you have done changes to the content of a submodule, they are not automatically pushed by pushing the main repository
|
|
|
Pushing changes to submodules
|
|
|
-----------------------------
|
|
|
If you have done changes to the content of a submodule, they are not automatically pushed by pushing the main repository. This is convenient if you use the submodule structure only as passive way to include content from a repository that you cannot write to yourself (but of which you would like to always have the latest version). In that case, any accidental changes to the submodule can simply reverted by doing **in the submodule folder**
|
|
|
```bash
|
|
|
git reset --hard
|
|
|
```
|
|
|
This will discard all changes and reset the submodule to the commit it is pointing to.
|
|
|
|
|
|
In case you would also like to do modifications to the submodule content and push your changes to the submodule repository, you have to first checkout a certain branch of the submodule repository (e.g., master):
|
|
|
```bash
|
|
|
git checkout <branch_name>
|
|
|
```
|
|
|
Then you can add, commit and push your changes:
|
|
|
```bash
|
|
|
git add .
|
|
|
git commit -m 'place your commit message here'
|
|
|
git push <remote branch name>
|
|
|
```
|
|
|
where the remote branch name could be, e.g., 'origin master' (that is, the master branch on the remote repository). After pushing to the submodule, you should still push the update on the main repository, in order to make the submodule point to the latest commit (the one you have just pushed): browse to the main repository and do
|
|
|
```bash
|
|
|
git add .
|
|
|
git commit -m 'commit message, e.g. update submodule (name_of_submodule)'
|
|
|
git push <remote branch name>
|
|
|
```
|
|
|
Now, the submodule structure on the main repository is synchronized again with your latest commit.
|
|
|
|
|
|
|
|
|
|