Components of the system such as the WP frontend https://github.com/OpenDevelopmentMekong/odm-frontend are composed by several elements. Since this other items are already hosted on github by their respective mantainers, these are reference within our repositories as submodules.
In case you do not know what submodules are, please read https://chrisjean.com/2009/04/20/git-submodules-adding-using-removing-and-updating/
Having a code repository containing submodules, changes slightly the way we work with it:
--recursive
flag. This way we are cloning every single git repository reference in ours as submodule. If not specified, just the folder will get downloaded, but not the contents of it.
Some of the repositories available on https://github.com/OpenDevelopmentMekong/ are actually clones of other repositories which we then have modified to some extent or are administering separatedly.
However, it can happen that the contributors of those parent repositories update the code which we will then want to integrate with ours. For that, we need to do the following:
git pull
to be sure to work with the most actual code
git remote add upstream <URL>
replacing <URL> with the URL of the parent repository (i.e: https://github.com/oeco/jeo.git) for adding a new remote on this local repository.
git fetch upstream
to bring the latest code changes on the parent repository to the local one
git merge upstream/<branch>
to merge the codes of the specified <branch> on the parent directory into the local repository.
git push
to push the merged code
Let's take the ODM Frontend repository as an example. If we navigate to wp-content/themes, we will see that both jeo and jeo-odm are included as submodules.
If we look closer, we notice the reference to the commit each of them is pointing to ( ae6906e for jeo and a1177e8 for jeo-odm). Clicking on them will take you to that particular commit in the original repository.
Now, let's say our jeo-odm repository ( remember, this is a fork of https://github.com/oeco/opendev-wptheme ) gets updated. This means that the HEAD commit of it is now different than a1177e8. We need to update the reference on our odm-frontend repository. For this:
git clone https://github.com/OpenDevelopmentMekong/odm-frontend.git --recursive
cd odm-frontend/wp-content/themes/jeo-odm
git pull
cd ../../../../odm-frontend
git status
the messages presented should be something like:
[user@computer odm-frontend]$ git status # On branch master # Changed but not updated: # (use "git add ..." to update what will be committed) # (use "git checkout -- ..." to discard changes in working directory) # # modified: wp-content/themes/jeo-odm (new commits) #
Our repository is now up-to-date, but what about our code on the Pre-/Production instance? We need to update it as well. Following the previous example, we have updated the references of the jeo-odm repository, if we want to update this particular element we have to: